From d2af59b754b1b14d6e0d4c34aa27157a8515d64a Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Mon, 18 May 2026 16:10:26 +0000 Subject: [PATCH] Fix: Improve file serving content-disposition and filename Co-authored-by: aider (gemini/gemini-2.5-pro) --- app/app.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/app.py b/app/app.py index d7d22b3..1c511dc 100644 --- a/app/app.py +++ b/app/app.py @@ -1383,7 +1383,12 @@ async def api_files_full(path_b64: str, request: Request): if not _is_safe_path(UPLOAD_ROOT, file_path) or not os.path.isfile(file_path): return Response(status_code=404) - return FileResponse(file_path) + mime_type, _ = mimetypes.guess_type(file_path) + disposition = "attachment" + if mime_type and (mime_type.startswith(('image/', 'video/', 'audio/', 'text/')) or mime_type == 'application/pdf'): + disposition = "inline" + + return FileResponse(file_path, content_disposition_type=disposition, filename=os.path.basename(rel_path)) @app.get("/api/files/zip/{path_b64}")