Skip to content

Commit 67a70bf

Browse files
authored
Merge pull request #1257 from clowder-framework/fix/download-content-type
Set mime type for downloaded file
2 parents 130ce2e + 5e69c6b commit 67a70bf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

backend/app/routers/files.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,12 @@ async def download_file(
349349
content = fs.get_object(settings.MINIO_BUCKET_NAME, bytes_file_id)
350350

351351
# Get content type & open file stream
352+
media_type = file.content_type.content_type
353+
if media_type == "N/A":
354+
media_type = "application/octet-stream"
352355
response = StreamingResponse(
353-
content.stream(settings.MINIO_UPLOAD_CHUNK_SIZE)
356+
content.stream(settings.MINIO_UPLOAD_CHUNK_SIZE),
357+
media_type=media_type,
354358
)
355359
response.headers["Content-Disposition"] = (
356360
"attachment; filename=%s" % file.name

0 commit comments

Comments
 (0)