mirror of
https://github.com/matrix-org/synapse-s3-storage-provider.git
synced 2024-10-23 07:29:40 +00:00
Allow configuration of region and access keys
Adds the option to set more boto3 options: region_name, aws_access_key_id, and aws_secret_access_key. This makes it easier to configure without having to be careful about some CLI tool having the correct configuration. Also allows setting the region name.
This commit is contained in:
parent
30c30447e7
commit
f4df1a69eb
1 changed files with 19 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue