Problem with unicode characters
When I try to set up to sendfile with spanish characters (like: á, é, í, ó, ú...) using nginx backend, the link of sendfile response its: 404 not found.
I was trying Bulgarian characters (like: А, Б, В, Г, Д....) and everything works with Nginx backned under Python 3.
Can you investigate where exactly the things get broken.
I suspect it's more to do with how the default encoding on the server is setup etc.
It could be related with server encoding, I don't remember right now and I can't tested, sorry.
The problem is that the URL that's handed to nginx via the X-Accel-Redirect header isn't quoted. If you use urllib.parse.quote() on the URL there're no problem. I was going to fix this and add general Python 3 support next week. Is there a chance a PR with these changes will get reviewed and merged?
Possibly. I started a new job 3 months ago and it's been pretty intense...
@lilspikey that's not much to go on. What would it take for you to review a PR?
The main thing that we ran into (using Python3) is the quote issue. What if I made a PR for that and updated the tests accordingly. Would you be able to review that within the month of July?
I have a suggestion for generating the value for X-Accel-Redirect. Why not simply use Django's FileSystemStorage for generating the url and also validating the path to the file.
We can have a sendfile_storage which will be:
sendfile_storage = FileSystemStorage(SENDFILE_ROOT, SENDFILE_URL)
And then calculating the internal URL will be just:
internal_url = sendfile_storage.url(filename)
I think that this will solve the problem with the encoding.
For more info https://docs.djangoproject.com/en/1.9/ref/files/storage/#the-filesystemstorage-class
@Proper-Job hopefully I could review it in July. If it's just the quoting, then it shouldn't be a large change, so should manage it. New job doesn't involve Django at all, so this would purely be done in personal time.
@vstoykov that looks like it might work, but for the sake of a small change it might be easier to just go with adding quoting for now.
I created a PR for this issue. I successfully tested it on nginx. https://github.com/johnsensible/django-sendfile/pull/54
Note that escaped URIs breaks support for Nginx versions older than 1.5.9 which isn't expecting them in the X-Accel-Redirect header.
I personally think this is fine seeming as it's either not-supporting a 3-year-old release of Nginx or not-supporting unicode file names. But I'm leaving this as a note for anyone noticing the breakage when upgrading sendfile.