[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:
2026-07-31 08:24:14 +12:00
parent 703f377b7f
commit 032ebc30a2

View File

@ -2325,7 +2325,11 @@ def export(request, q: Query[PackageExportInSchema]):
exporter = PathwayExporter(p, add_infs_to_export=ai_types)
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:
return 403, {
"message": f"Exporting Package with id {q.package_uuid} failed due to insufficient rights!"