You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm tried extremely simple configuration based on examples from manual.
Files with latin filenames served well but for files like ИП_ТУ.odt (Cyrillic) code 404 returned.
Some useful logs:
nginx error.log:
2015/09/03 00:28:37 [error] 14503#0: *7 open() "/full/path/%D0%98%D0%9F_%D0%A2%D0%A3.odt" failed (2: No such file or directory), client: 192.168.2.2, server: server, request: "GET /path/%D0%98%D0%9F_%D0%A2%D0%A3.odt HTTP/1.1", upstream: "uwsgi://unix:///some.sock", host: "server"
uwsgi emperror.log:
[pid: 14496|app: 0|req: 1/5] 192.168.2.2 () {44 vars in 814 bytes} [Thu Sep 3 00:28:37 2015] GET /path/%D0%98%D0%9F_%D0%A2%D0%A3.odt => generated 0 bytes in 131 msecs (HTTP/1.1 200) 5 headers in 424 bytes (1 switches on core 0)
So the problem is quoted %XX-symbols, nginx trying to find files with exactly path (with %XX-symbols). Probably conversion is required before passing filename to web-server.
Also FileNotFoundError exception doesn't catch up if file not found.
File "/myapp/venv/lib/python3.4/site-packages/django_downloadview/response.py", line 182, in default_headers
headers['Content-Length'] = self.file.size
File "/myapp/venv/lib/python3.4/site-packages/django_downloadview/files.py", line 107, in size
return self.storage.size(self.name)
File "/myapp/venv/lib/python3.4/site-packages/django/core/files/storage.py", line 311, in size
return os.path.getsize(self.path(name))
File "/myapp/venv/lib/python3.4/genericpath.py", line 50, in getsize
return os.stat(filename).st_size
FileNotFoundError: [Errno 2] No such file or directory: '/full/path/ИП_ТУ.odttt'
The text was updated successfully, but these errors were encountered:
For catch FileNotFoundError exception you may change BaseDownloadView get() method to
classBaseDownloadView(DownloadMixin, View):
"""A base :class:`DownloadMixin` that implements :meth:`get`."""defget(self, request, *args, **kwargs):
"""Handle GET requests: stream a file."""try:
returnself.render_to_response()
exceptFileNotFoundError:
returnself.file_not_found_response()
This hack allow download files with non-ACSII name, but proposing filename for saving is %-quoted which is ugly.
For make request for non US-ACSII filename correct need to change content_disposition() function to use filename instead of utf8_filename:
I'm tried extremely simple configuration based on examples from manual.
Files with latin filenames served well but for files like ИП_ТУ.odt (Cyrillic) code 404 returned.
Some useful logs:
So the problem is quoted %XX-symbols, nginx trying to find files with exactly path (with %XX-symbols). Probably conversion is required before passing filename to web-server.
Also FileNotFoundError exception doesn't catch up if file not found.
The text was updated successfully, but these errors were encountered: