From ddac34f769baf015e9bc2bf975d7fe2ed742df9d Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 18 Dec 2024 18:15:58 -0800 Subject: [PATCH] refac --- backend/open_webui/routers/files.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/open_webui/routers/files.py b/backend/open_webui/routers/files.py index fa36a03ea..3b1ba2945 100644 --- a/backend/open_webui/routers/files.py +++ b/backend/open_webui/routers/files.py @@ -226,9 +226,16 @@ async def get_file_content_by_id(id: str, user=Depends(get_verified_user)): # Handle Unicode filenames filename = file.meta.get("name", file.filename) encoded_filename = quote(filename) # RFC5987 encoding - headers = { - "Content-Disposition": f"attachment; filename*=UTF-8''{encoded_filename}" - } + + headers = {} + if file.meta.get("content_type") not in [ + "application/pdf", + "text/plain", + ]: + headers = { + **headers, + "Content-Disposition": f"attachment; filename*=UTF-8''{encoded_filename}", + } return FileResponse(file_path, headers=headers)