diff --git a/backend/app/api/media.py b/backend/app/api/media.py index 1eb54e1..6f17898 100644 --- a/backend/app/api/media.py +++ b/backend/app/api/media.py @@ -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}")