Not sure, but perhaps you need quotes around the file name to avoid having
the user agent terminate the filename on space?  E.g.;
    ..."attachement; filename=" + '"' + rep_setup......+ '.xlsx"'


On Fri, Oct 11, 2013 at 6:27 AM, DJ-Tom <eventel...@gmail.com> wrote:

> 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
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/02885902-24e2-4618-9093-d7be1e97ac30%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0tmw3Ro4fNVqYSukkwQTJZ-XU_75wgtCfUqs3wHS1qpSw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to