Fix MP3 download python error

This commit is contained in:
Koper
2023-10-13 10:37:45 +01:00
parent f8dfa61fe0
commit 1a7da94cae
2 changed files with 8 additions and 2 deletions

View File

@@ -38,7 +38,9 @@ def _get_range_header(range_header: str, file_size: int) -> tuple[int, int]:
return start, end
def range_requests_response(request: Request, file_path: str, content_type: str):
def range_requests_response(
request: Request, file_path: str, content_type: str, content_disposition: str
):
"""Returns StreamingResponse using Range Requests of a given file"""
file_size = os.stat(file_path).st_size
@@ -54,6 +56,10 @@ def range_requests_response(request: Request, file_path: str, content_type: str)
"content-range, content-encoding"
),
}
if content_disposition:
headers["Content-Disposition"] = content_disposition
start = 0
end = file_size - 1
status_code = status.HTTP_200_OK

View File

@@ -363,7 +363,7 @@ async def transcript_get_audio_mp3(
request,
transcript.audio_mp3_filename,
content_type="audio/mpeg",
headers={"Content-Disposition": f"attachment; filename={filename}"},
content_disposition=f"attachment; filename={filename}",
)