fix(file-summary): 修复报告导出下载
This commit is contained in:
@@ -121,4 +121,14 @@ def export_download(request, export_id: int):
|
||||
path = Path(exported.storage_path)
|
||||
if not path.exists():
|
||||
return JsonResponse({"error": "文件不存在。"}, status=404)
|
||||
return FileResponse(path.open("rb"), as_attachment=True, filename=exported.file_name)
|
||||
content_type = (
|
||||
"text/markdown; charset=utf-8"
|
||||
if exported.export_type == ExportedSummaryFile.ExportType.MARKDOWN
|
||||
else "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
)
|
||||
return FileResponse(
|
||||
path.open("rb"),
|
||||
as_attachment=True,
|
||||
filename=exported.file_name,
|
||||
content_type=content_type,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user