Commits

Anonymous committed a929572 Draft

Added NO_SCHEMA option. Defaults to False. If set to True the url is returned without the schema. This is useful for sites that have secure and non-secure areas.

  • Participants
  • Parent commits 02c77e7

Comments (0)

Files changed (1)

storages/backends/s3boto.py

 FILE_BUFFER_SIZE = getattr(settings, 'AWS_S3_FILE_BUFFER_SIZE', 5242880)
 IS_GZIPPED = getattr(settings, 'AWS_IS_GZIPPED', False)
 PRELOAD_METADATA = getattr(settings, 'AWS_PRELOAD_METADATA', False)
+NO_SCHEMA = getattr(settings, 'AWS_NO_SCHEMA', False)
 GZIP_CONTENT_TYPES = getattr(settings, 'GZIP_CONTENT_TYPES', (
     'text/css',
     'application/javascript',
             querystring_expire=QUERYSTRING_EXPIRE,
             reduced_redundancy=REDUCED_REDUNDANCY,
             custom_domain=CUSTOM_DOMAIN,
+            no_schema=NO_SCHEMA,
             secure_urls=SECURE_URLS,
             location=LOCATION,
             file_name_charset=FILE_NAME_CHARSET,
         self.querystring_expire = querystring_expire
         self.reduced_redundancy = reduced_redundancy
         self.custom_domain = custom_domain
+        self.no_schema = no_schema
         self.secure_urls = secure_urls
         self.location = location or ''
         self.location = self.location.lstrip('/')
     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',
+
+            if self.no_schema:
+                return "//%s/%s" % (self.custom_domain, name)
+            else:
+                return "%s://%s/%s" % ('https' if self.secure_urls else 'http',
                                    self.custom_domain, 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)