Pull requests

#66 Merged
Repository
fmartingr fmartingr
Branch
custom_host
Repository
david david
Branch
default

s3boto backend: Allows custom S3 host, port and choose if connection is secure

Author
  1. Felipe Martín
Reviewers
Description

Allowing a custom host and port to the S3Boto backend let developers test using fakes3 in local/development environments.

I've updated the settings with AWS_S3_HOST and AWS_S3_PORT, defaults to None. If no custom host is entered, the default connection is made.

Also, added AWS_S3_USE_SSL, default to True. This changes the is_secure parameter for the S3 connection.

  • Learn about pull requests

Comments (4)

  1. k4ml

    Using S3Connection.DefaultHost as fallback will make the changes simpler I think:-

    diff -r c751701f596d storages/backends/s3boto.py
    --- a/storages/backends/s3boto.py       Sun Mar 31 10:10:17 2013 -0400
    +++ b/storages/backends/s3boto.py       Fri Apr 05 00:46:06 2013 +0900
    @@ -223,6 +223,9 @@
         encryption = setting('AWS_S3_ENCRYPTION', False)
         custom_domain = setting('AWS_S3_CUSTOM_DOMAIN')
         calling_format = setting('AWS_S3_CALLING_FORMAT', SubdomainCallingFormat())
    +    host = setting('AWS_S3_HOST', S3Connection.DefaultHost)
    +    use_ssl = setting('AWS_S3_USE_SSL', True)
    +    port = setting('AWS_S3_PORT', None)
         secure_urls = setting('AWS_S3_SECURE_URLS', True)
         file_name_charset = setting('AWS_S3_FILE_NAME_CHARSET', 'utf-8')
         gzip = setting('AWS_IS_GZIPPED', False)
    @@ -266,6 +269,7 @@
             if self._connection is None:
                 self._connection = self.connection_class(
                     self.access_key, self.secret_key,
    +                host=self.host, port=self.port, is_secure=self.use_ssl,
                     calling_format=self.calling_format)
             return self._connection