fix(media): corriger import ALLOWED_AUDIO_PREFIXES et strip codec MIME
ImportError au démarrage du backend : ALLOWED_AUDIO_TYPES avait été renommé en ALLOWED_AUDIO_PREFIXES dans services/media.py mais l'import dans api/media.py n'avait pas été mis à jour. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ from fastapi import APIRouter, UploadFile, File, Query, HTTPException
|
||||
from fastapi.responses import Response
|
||||
|
||||
from app.schemas.media import MediaUploadResponse
|
||||
from app.services.media import save_image, save_audio, delete_media, ALLOWED_IMAGE_TYPES, ALLOWED_AUDIO_TYPES
|
||||
from app.services.media import save_image, save_audio, delete_media, ALLOWED_IMAGE_TYPES, ALLOWED_AUDIO_PREFIXES
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -12,10 +12,10 @@ async def upload_media(
|
||||
file: UploadFile = File(...),
|
||||
context: str = Query(default="note", pattern="^(product|note|attachment)$"),
|
||||
):
|
||||
content_type = (file.content_type or "").lower()
|
||||
content_type = (file.content_type or "").lower().split(";")[0].strip()
|
||||
if content_type in ALLOWED_IMAGE_TYPES:
|
||||
result = await save_image(file, context=context)
|
||||
elif content_type in ALLOWED_AUDIO_TYPES:
|
||||
elif content_type in ALLOWED_AUDIO_PREFIXES:
|
||||
result = await save_audio(file)
|
||||
else:
|
||||
raise HTTPException(status_code=400, detail=f"Type de fichier non supporté : {content_type}")
|
||||
|
||||
Reference in New Issue
Block a user