1. David Larlet
  2. django-storages

Commits

Felipe Martín  committed deee056

+ s3boto backend: Allows custom S3 host and port.

  • Participants
  • Parent commits 02afdf3
  • Branches custom_host

Comments (0)

Files changed (1)

File storages/backends/s3boto.py

View file
  • Ignore whitespace
         'application/x-javascript',
     ))
     url_protocol = setting('AWS_S3_URL_PROTOCOL', 'http:')
+    host = setting('AWS_S3_HOST', None)
+    port = setting('AWS_S3_PORT', None)
 
     def __init__(self, acl=None, bucket=None, **settings):
         # check if some of the settings we've provided as class attributes
     @property
     def connection(self):
         if self._connection is None:
-            self._connection = self.connection_class(
-                self.access_key, self.secret_key,
-                calling_format=self.calling_format)
+            if self.host is None:
+                # Using real Amazon S3 server
+                self._connection = self.connection_class(
+                    self.access_key,
+                    self.secret_key,
+                    calling_format=self.calling_format
+                )
+            else:
+                # Using custom S3 server
+                self._connection = self.connection_class(
+                    self.access_key,
+                    self.secret_key,
+                    calling_format=self.calling_format,
+                    host=self.host,
+                    port=self.port
+                )
         return self._connection
 
     @property