forked from enviPath/enviPy
[Fix] Return a File instead of raw text for new export endpoint (#442)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#442
This commit is contained in:
@ -2325,7 +2325,11 @@ def export(request, q: Query[PackageExportInSchema]):
|
|||||||
exporter = PathwayExporter(p, add_infs_to_export=ai_types)
|
exporter = PathwayExporter(p, add_infs_to_export=ai_types)
|
||||||
res = exporter.do_export()
|
res = exporter.do_export()
|
||||||
|
|
||||||
return res
|
filename = f"{p.get_name().replace(' ', '_')}_{p.uuid}.tsv"
|
||||||
|
response = HttpResponse(res, content_type="text/csv")
|
||||||
|
response["Content-Disposition"] = f'attachment; filename="{filename}"'
|
||||||
|
|
||||||
|
return response
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return 403, {
|
return 403, {
|
||||||
"message": f"Exporting Package with id {q.package_uuid} failed due to insufficient rights!"
|
"message": f"Exporting Package with id {q.package_uuid} failed due to insufficient rights!"
|
||||||
|
|||||||
Reference in New Issue
Block a user