Felipe Martín avatar Felipe Martín committed deee056

+ s3boto backend: Allows custom S3 host and port.

Comments (0)

Files changed (1)

storages/backends/s3boto.py

         '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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.