Hi,
I'm serving files via HttpResponse and currently I'm struggling with spaces in the filenames.
This is how I contruct the response header:
response = HttpResponse(report.reportfile.chunks(), mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
response['Content-Disposition'] = "attachment; filename=" + rep_setup.name.encode("ASCII") + "." + report.date_run.strftime("%Y-%m-%d.%H%M") + ".xlsx"
report.reportfile.close()
return response
But if rep_setup.filename contains spaces, the browser (Firefox) truncates the filename at that position.
I tried to use django.utils.http.urlqoute(), but a filename like this looks just ugly: Some%20long%20Filename%20with%20Spaces.xlsx
Or should I just replace all Spaces with a underscore "_" character?
What is the technically correct way?
Thomas