refac
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
Integration Test / Run Cypress Integration Tests (push) Waiting to run
Integration Test / Run Migration Tests (push) Waiting to run

This commit is contained in:
Timothy Jaeryang Baek 2024-12-18 18:15:58 -08:00
parent 2875326015
commit ddac34f769

View File

@ -226,8 +226,15 @@ async def get_file_content_by_id(id: str, user=Depends(get_verified_user)):
# Handle Unicode filenames # Handle Unicode filenames
filename = file.meta.get("name", file.filename) filename = file.meta.get("name", file.filename)
encoded_filename = quote(filename) # RFC5987 encoding encoded_filename = quote(filename) # RFC5987 encoding
headers = {}
if file.meta.get("content_type") not in [
"application/pdf",
"text/plain",
]:
headers = { headers = {
"Content-Disposition": f"attachment; filename*=UTF-8''{encoded_filename}" **headers,
"Content-Disposition": f"attachment; filename*=UTF-8''{encoded_filename}",
} }
return FileResponse(file_path, headers=headers) return FileResponse(file_path, headers=headers)