Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode filenames with X-Sendfile + Apache #32

Open
perstar opened this issue Mar 13, 2019 · 0 comments
Open

Unicode filenames with X-Sendfile + Apache #32

perstar opened this issue Mar 13, 2019 · 0 comments

Comments

@perstar
Copy link

perstar commented Mar 13, 2019

I struggled to get Unicode filenames to work when serving with X-Sendfile via Apache. (Where it worked in the development server.) This was with Python 2 (and Django 1.11). I haven't tested with later versions.

It turned out that when setting a header on a django.http.HttpResponse object to a Unicode string the value instead became a str object which didn't work well when the response object was later used. It works for me by just changing response['X-Sendfile'] = private_file.full_path (which was a unicode) by adding .encode('utf-8') to the end of it in serve in ApacheXSendFileServer in servers.py.

This is the quick fix for me (except it really wasn't quick :-) which might need embellishing to work with different versions and maybe to check what the actual encoding of filenames should be, but hopefully useful as a start or as something to copy for others with the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant