Features:;
Fixes:; Extra: 1) Simplify `FileResponse` usage and reduce redundant code in file download logic;.
This commit is contained in:
parent
9b47f6dd7b
commit
83ce862a83
1 changed files with 4 additions and 5 deletions
|
|
@ -488,11 +488,10 @@ def download_digital_asset_view(request, *args, **kwargs):
|
|||
if not content_type:
|
||||
content_type = "application/octet-stream"
|
||||
|
||||
with open(file_path, "rb") as file:
|
||||
response = FileResponse(file, content_type=content_type)
|
||||
filename = os.path.basename(file_path)
|
||||
response["Content-Disposition"] = f'attachment; filename="{filename}"'
|
||||
return response
|
||||
response = FileResponse(open(file_path, "rb"), content_type=content_type)
|
||||
filename = os.path.basename(file_path)
|
||||
response["Content-Disposition"] = f'attachment; filename="{filename}"'
|
||||
return response
|
||||
|
||||
except BadRequest as e:
|
||||
return JsonResponse(camelize({"error": str(e)}), status=400)
|
||||
|
|
|
|||
Loading…
Reference in a new issue