Update download_file function to include headers for file download
This commit is contained in:
parent
9968a6b134
commit
4f6d5fe5d8
1 changed files with 6 additions and 1 deletions
|
|
@ -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))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue