Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion audio_separator/remote/deploy_modal.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from importlib.metadata import version
import typing
from typing import Optional
from urllib.parse import quote

# Third-party imports
from fastapi import FastAPI, File, Form, HTTPException, Response, UploadFile
Expand Down Expand Up @@ -712,7 +713,13 @@ async def download_file(task_id: str, file_hash: str) -> Response:
print(f"WARNING: Could not detect MIME type for {actual_filename}, using generic type")
content_type = "application/octet-stream"

return Response(content=file_data, media_type=content_type, headers={"Content-Disposition": f"attachment; filename={actual_filename}"})
# RFC 5987 encoding for Unicode filenames in Content-Disposition header
# Provide ASCII fallback for older clients, and UTF-8 encoded filename for modern clients
ascii_filename = "".join(c if ord(c) < 128 else "_" for c in actual_filename)
encoded_filename = quote(actual_filename, safe="")
content_disposition = f"attachment; filename=\"{ascii_filename}\"; filename*=UTF-8''{encoded_filename}"

return Response(content=file_data, media_type=content_type, headers={"Content-Disposition": content_disposition})

except FileNotFoundError as exc:
raise HTTPException(status_code=404, detail="File not found") from exc
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "audio-separator"
version = "0.41.0"
version = "0.41.1"
description = "Easy to use audio stem separation, using various models from UVR trained primarily by @Anjok07"
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
license = "MIT"
Expand Down