mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
Fix MP3 download python error
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}",
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user