diff --git a/s3_storage_provider.py b/s3_storage_provider.py index ecfb074..d15d35c 100644 --- a/s3_storage_provider.py +++ b/s3_storage_provider.py @@ -51,9 +51,19 @@ class S3StorageProviderBackend(StorageProvider): self.bucket = config["bucket"] self.storage_class = config["storage_class"] self.api_kwargs = {} + + if "region_name" in config: + self.api_kwargs["region_name"] = config["region_name"] + if "endpoint_url" in config: self.api_kwargs["endpoint_url"] = config["endpoint_url"] + if "access_key_id" in config: + self.api_kwargs["aws_access_key_id"] = config["access_key_id"] + + if "secret_access_key" in config: + self.api_kwargs["aws_secret_access_key"] = config["secret_access_key"] + def store_file(self, path, file_info): """See StorageProvider.store_file""" @@ -95,9 +105,18 @@ class S3StorageProviderBackend(StorageProvider): "storage_class": storage_class, } + if "region_name" in config: + result["region_name"] = config["region_name"] + if "endpoint_url" in config: result["endpoint_url"] = config["endpoint_url"] + if "access_key_id" in config: + result["access_key_id"] = config["access_key_id"] + + if "secret_access_key" in config: + result["secret_access_key"] = config["secret_access_key"] + return result