Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Now supporting Unicode filenames properly.

  • Loading branch information...
commit 3692097460a05376ae66b69faa24ff444a85996a 1 parent 47bc2e8
@Aramgutang Aramgutang authored
Showing with 10 additions and 5 deletions.
  1. +10 −5 fallbackserve/storage.py
View
15 fallbackserve/storage.py
@@ -1,8 +1,11 @@
-from django.core.files.storage import FileSystemStorage
-from django.core.files.base import ContentFile
-import urllib2
import os
+import urllib
+import urllib2
+
from django.conf import settings
+from django.core.files.base import ContentFile
+from django.core.files.storage import FileSystemStorage
+from django.utils.encoding import smart_str
class FallbackStorage(FileSystemStorage):
@@ -45,9 +48,11 @@ def fetch_remote(self, name):
if name.startswith(settings.MEDIA_ROOT):
name = name[len(settings.MEDIA_ROOT):].lstrip('/')
if settings.MEDIA_URL.startswith('http://'):
- fq_url = '%s/%s' % (settings.MEDIA_URL.rstrip('/'), name)
+ media_server = settings.MEDIA_URL.rstrip('/')
else:
- fq_url = '%s/%s' % (fallback_server.rstrip('/'), name)
+ media_server = fallback_server.rstrip('/')
+ # Convert the filename into bytes (if it's Unicode) and escape chars
+ fq_url = '%s/%s' % (media_server, urllib.quote(smart_str(name)))
print "FallbackStorage: trying to fetch from %s" % fq_url
try:
handlers = []
Please sign in to comment.
Something went wrong with that request. Please try again.