1. David Larlet
  2. django-storages
  3. Issues


Issue #113 resolved

s3Boto backend should filepath_to_uri the name when using a custom_domain

Jason Culverhouse
created an issue

When S3BotoStorage.url("name with space") is called and a custom domain is set the file part is not properly encoded.

AWS_S3_CUSTOM_DOMAIN not set: S3BotoStorage.url("name with space") returns http://bucket.name.s3.amazonaws.com/name%20with%20space

AWS_S3_CUSTOM_DOMAIN = "bucket.name" "http://bucket.name/name with space"

see https://bitbucket.org/david/django-storages/src/83fa2f0ba20c/storages/backends/s3boto.py#cl-340



from django.utils.encoding import filepath_to_uri


class S3BotoStorage(Storage): ... def url(self, name): name = self._normalize_name(self._clean_name(name)) if self.custom_domain: return "%s://%s/%s" % ('https' if self.secure_urls else 'http', self.custom_domain, filepath_to_uri(name)) return self.connection.generate_url(self.querystring_expire, method='GET', bucket=self.bucket.name, key=self._encode_name(name), query_auth=self.querystring_auth, force_http=not self.secure_urls)


Comments (3)

  1. Log in to comment