Esempio n. 1
0
    def __init__(self, acl=None, bucket=None, **settings):
        # check if some of the settings we've provided as class attributes
        # need to be overwritten with values passed in here
        for name, value in settings.items():
            if hasattr(self, name):
                setattr(self, name, value)

        # For backward-compatibility of old differing parameter names
        if acl is not None:
            self.default_acl = acl
        if bucket is not None:
            self.bucket_name = bucket

        check_location(self)

        # Backward-compatibility: given the anteriority of the SECURE_URL setting
        # we fall back to https if specified in order to avoid the construction
        # of unsecure urls.
        if self.secure_urls:
            self.url_protocol = 'https:'

        self._entries = {}
        self._bucket = None
        self._connection = None
        self._loaded_meta = False

        self.access_key, self.secret_key = self._get_access_keys()
        self.security_token = self._get_security_token()
Esempio n. 2
0
    def __init__(self, acl=None, bucket=None, **settings):
        # check if some of the settings we've provided as class attributes
        # need to be overwritten with values passed in here
        for name, value in settings.items():
            if hasattr(self, name):
                setattr(self, name, value)

        # For backward-compatibility of old differing parameter names
        if acl is not None:
            self.default_acl = acl
        if bucket is not None:
            self.bucket_name = bucket

        check_location(self)

        # Backward-compatibility: given the anteriority of the SECURE_URL setting
        # we fall back to https if specified in order to avoid the construction
        # of unsecure urls.
        if self.secure_urls:
            self.url_protocol = 'https:'

        self._entries = {}
        self._bucket = None
        self._connection = None
        self._loaded_meta = False

        self.access_key, self.secret_key = self._get_access_keys()
        self.security_token = self._get_security_token()
Esempio n. 3
0
    def __init__(self, **settings):
        super().__init__(**settings)

        check_location(self)

        self._bucket = None
        self._client = None
Esempio n. 4
0
    def __init__(self, **settings):
        # check if some of the settings we've provided as class attributes
        # need to be overwritten with values passed in here
        for name, value in settings.items():
            if hasattr(self, name):
                setattr(self, name, value)

        check_location(self)

        self._bucket = None
        self._client = None
Esempio n. 5
0
    def __init__(self, acl=None, bucket=None, **settings):
        # check if some of the settings we've provided as class attributes
        # need to be overwritten with values passed in here
        for name, value in settings.items():
            if hasattr(self, name):
                setattr(self, name, value)

        # For backward-compatibility of old differing parameter names
        if acl is not None:
            warnings.warn(
                "The acl argument of S3Boto3Storage is deprecated. Use "
                "argument default_acl or setting AWS_DEFAULT_ACL instead. The "
                "acl argument will be removed in version 2.0.",
                DeprecationWarning,
            )
            self.default_acl = acl
        if bucket is not None:
            warnings.warn(
                "The bucket argument of S3Boto3Storage is deprecated. Use "
                "argument bucket_name or setting AWS_STORAGE_BUCKET_NAME "
                "instead. The bucket argument will be removed in version 2.0.",
                DeprecationWarning,
            )
            self.bucket_name = bucket

        check_location(self)

        # Backward-compatibility: given the anteriority of the SECURE_URL setting
        # we fall back to https if specified in order to avoid the construction
        # of unsecure urls.
        if self.secure_urls:
            self.url_protocol = 'https:'

        self._entries = {}
        self._bucket = None
        self._connections = threading.local()

        self.access_key, self.secret_key = self._get_access_keys()
        self.security_token = self._get_security_token()

        if not self.config:
            self.config = Config(
                s3={'addressing_style': self.addressing_style},
                signature_version=self.signature_version)

        # warn about upcoming change in default AWS_DEFAULT_ACL setting
        if not hasattr(django_settings, 'AWS_DEFAULT_ACL'):
            warnings.warn(
                "The default behavior of S3Boto3Storage is insecure and will change "
                "in django-storages 2.0. By default files and new buckets are saved "
                "with an ACL of 'public-read' (globally publicly readable). Version 2.0 will "
                "default to using the bucket's ACL. To opt into the new behavior set "
                "AWS_DEFAULT_ACL = None, otherwise to silence this warning explicitly "
                "set AWS_DEFAULT_ACL.")
Esempio n. 6
0
    def __init__(self, **settings):
        super(GoogleCloudStorage, self).__init__(**settings)

        check_location(self)

        if self.auto_create_bucket:
            warnings.warn(
                "Automatic bucket creation will be removed in version 1.10. It encourages "
                "using overly broad credentials with this library. Either create it before "
                "manually or use one of a myriad of automatic configuration management tools. "
                "Unset GS_AUTO_CREATE_BUCKET (it defaults to False) to silence this warning.",
                DeprecationWarning,
            )

        self._bucket = None
        self._client = None
Esempio n. 7
0
    def __init__(self, **settings):
        # check if some of the settings we've provided as class attributes
        # need to be overwritten with values passed in here
        for name, value in settings.items():
            if hasattr(self, name):
                setattr(self, name, value)

        check_location(self)

        if self.auto_create_bucket:
            warnings.warn(
                "Automatic bucket creation will be removed in version 1.10. It encourages "
                "using overly broad credentials with this library. Either create it before "
                "manually or use one of a myriad of automatic configuration management tools. "
                "Unset GS_AUTO_CREATE_BUCKET (it defaults to False) to silence this warning.",
                DeprecationWarning,
            )

        self._bucket = None
        self._client = None
Esempio n. 8
0
    def __init__(self, **settings):
        super().__init__(**settings)

        check_location(self)

        # Backward-compatibility: given the anteriority of the SECURE_URL setting
        # we fall back to https if specified in order to avoid the construction
        # of unsecure urls.
        if self.secure_urls:
            self.url_protocol = 'https:'

        self._bucket = None
        self._external_bucket = None
        self._connections = threading.local()

        if not self.config:
            self.config = Config(
                s3={'addressing_style': self.addressing_style},
                signature_version=self.signature_version,
                proxies=self.proxies,
            )
Esempio n. 9
0
    def __init__(self, acl=None, bucket=None, **settings):
        super().__init__(**settings)

        # For backward-compatibility of old differing parameter names
        if acl is not None:
            warnings.warn(
                "The acl argument of S3Boto3Storage is deprecated. Use "
                "argument default_acl or setting AWS_DEFAULT_ACL instead. The "
                "acl argument will be removed in version 1.10.",
                DeprecationWarning,
            )
            self.default_acl = acl
        if bucket is not None:
            warnings.warn(
                "The bucket argument of S3Boto3Storage is deprecated. Use "
                "argument bucket_name or setting AWS_STORAGE_BUCKET_NAME "
                "instead. The bucket argument will be removed in version 1.10.",
                DeprecationWarning,
            )
            self.bucket_name = bucket
        if self.auto_create_bucket:
            warnings.warn(
                "Automatic bucket creation will be removed in version 1.10. It encourages "
                "using overly broad credentials with this library. Either create it before "
                "manually or use one of a myriad of automatic configuration management tools. "
                "Unset AWS_AUTO_CREATE_BUCKET (it defaults to False) to silence this warning.",
                DeprecationWarning,
            )
        if self.reduced_redundancy:
            warnings.warn(
                "Support for AWS_REDUCED_REDUNDANCY will be removed in version 1.10. "
                "Update now by adding StorageClass=REDUCED_REDUNDANCY to "
                "AWS_S3_OBJECT_PARAMETERS. There are also several other possible values "
                "for StorageClass available. Check the AWS & boto3 docs for more info.",
                DeprecationWarning,
            )
        if self.encryption:
            warnings.warn(
                "Support for AWS_S3_ENCRYPTION will be removed in version 1.10. "
                "Update now by adding ServerSideEncryption=AES256 to "
                "AWS_S3_OBJECT_PARAMETERS. Doing so also easily allows using 'aws:kms' "
                "for encryption. Check the AWS & boto3 docs for more info.",
                DeprecationWarning,
            )
        if self.preload_metadata:
            warnings.warn(
                "Support for AWS_PRELOAD_METADATA will be removed in version 1.10. ",
                DeprecationWarning,
            )

        check_location(self)

        # Backward-compatibility: given the anteriority of the SECURE_URL setting
        # we fall back to https if specified in order to avoid the construction
        # of unsecure urls.
        if self.secure_urls:
            self.url_protocol = 'https:'

        self._entries = {}
        self._bucket = None
        self._connections = threading.local()

        self.access_key, self.secret_key = self._get_access_keys()
        self.security_token = self._get_security_token()

        if not self.config:
            kwargs = dict(
                s3={'addressing_style': self.addressing_style},
                signature_version=self.signature_version,
            )

            if boto3_version_info >= (1, 4, 4):
                kwargs['proxies'] = self.proxies
            else:
                warnings.warn(
                    "In version 1.10 of django-storages the minimum required version of "
                    "boto3 will be 1.4.4. You have %s " % boto3_version_info)
            self.config = Config(**kwargs)

        # warn about upcoming change in default AWS_DEFAULT_ACL setting
        if not hasattr(
                django_settings,
                'AWS_DEFAULT_ACL') and self.default_acl == 'public-read':
            warnings.warn(
                "The default behavior of S3Boto3Storage is insecure and will change "
                "in django-storages 1.10. By default files and new buckets are saved "
                "with an ACL of 'public-read' (globally publicly readable). Version 1.10 will "
                "default to using the bucket's ACL. To opt into the new behavior set "
                "AWS_DEFAULT_ACL = None, otherwise to silence this warning explicitly "
                "set AWS_DEFAULT_ACL.")
Esempio n. 10
0
    def __init__(self, acl=None, bucket=None, **settings):
        # check if some of the settings we've provided as class attributes
        # need to be overwritten with values passed in here
        for name, value in settings.items():
            if hasattr(self, name):
                setattr(self, name, value)

        # For backward-compatibility of old differing parameter names
        if acl is not None:
            warnings.warn(
                "The acl argument of S3Boto3Storage is deprecated. Use "
                "argument default_acl or setting AWS_DEFAULT_ACL instead. The "
                "acl argument will be removed in version 2.0.",
                DeprecationWarning,
            )
            self.default_acl = acl
        if bucket is not None:
            warnings.warn(
                "The bucket argument of S3Boto3Storage is deprecated. Use "
                "argument bucket_name or setting AWS_STORAGE_BUCKET_NAME "
                "instead. The bucket argument will be removed in version 2.0.",
                DeprecationWarning,
            )
            self.bucket_name = bucket

        check_location(self)

        # Backward-compatibility: given the anteriority of the SECURE_URL setting
        # we fall back to https if specified in order to avoid the construction
        # of unsecure urls.
        if self.secure_urls:
            self.url_protocol = 'https:'

        self._entries = {}
        self._bucket = None
        self._connections = threading.local()

        self.access_key, self.secret_key = self._get_access_keys()
        self.security_token = self._get_security_token()

        if not self.config:
            kwargs = dict(
                s3={'addressing_style': self.addressing_style},
                signature_version=self.signature_version,
            )

            if boto3_version_info >= (1, 4, 4):
                kwargs['proxies'] = self.proxies
            else:
                warnings.warn(
                    "In version 2.0 of django-storages the minimum required version of "
                    "boto3 will be 1.4.4. You have %s " % boto3_version_info
                )
            self.config = Config(**kwargs)

        # warn about upcoming change in default AWS_DEFAULT_ACL setting
        if not hasattr(django_settings, 'AWS_DEFAULT_ACL') and self.default_acl == 'public-read':
            warnings.warn(
                "The default behavior of S3Boto3Storage is insecure and will change "
                "in django-storages 2.0. By default files and new buckets are saved "
                "with an ACL of 'public-read' (globally publicly readable). Version 2.0 will "
                "default to using the bucket's ACL. To opt into the new behavior set "
                "AWS_DEFAULT_ACL = None, otherwise to silence this warning explicitly "
                "set AWS_DEFAULT_ACL."
            )