From 4f6d5fe5d833fc9265b40e03ebe244d0269c99b1 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 29 Jan 2024 10:18:52 -0300 Subject: [PATCH] Update download_file function to include headers for file download --- src/backend/langflow/api/v1/files.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/api/v1/files.py b/src/backend/langflow/api/v1/files.py index a48e18ed4..722a79c03 100644 --- a/src/backend/langflow/api/v1/files.py +++ b/src/backend/langflow/api/v1/files.py @@ -63,7 +63,12 @@ async def download_file( raise HTTPException(status_code=500, detail=f"Content type not found for extension {extension}") file_content = storage_service.get_file(flow_id=flow_id, file_name=file_name) - return StreamingResponse(BytesIO(file_content), media_type=content_type) + headers = { + "Content-Disposition": f"attachment; filename={file_name} filename*=UTF-8''{file_name}", + "Content-Type": "application/octet-stream", + "Content-Length": str(len(file_content)), + } + return StreamingResponse(BytesIO(file_content), media_type=content_type, headers=headers) except Exception as e: raise HTTPException(status_code=500, detail=str(e))