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:
|
if not content_type:
|
||||||
content_type = "application/octet-stream"
|
content_type = "application/octet-stream"
|
||||||
|
|
||||||
with open(file_path, "rb") as file:
|
response = FileResponse(open(file_path, "rb"), content_type=content_type)
|
||||||
response = FileResponse(file, content_type=content_type)
|
filename = os.path.basename(file_path)
|
||||||
filename = os.path.basename(file_path)
|
response["Content-Disposition"] = f'attachment; filename="{filename}"'
|
||||||
response["Content-Disposition"] = f'attachment; filename="{filename}"'
|
return response
|
||||||
return response
|
|
||||||
|
|
||||||
except BadRequest as e:
|
except BadRequest as e:
|
||||||
return JsonResponse(camelize({"error": str(e)}), status=400)
|
return JsonResponse(camelize({"error": str(e)}), status=400)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue