sams.storage.providers.amazon
– Amazon S3 Storage Provider¶
Amazon S3 Storage Provider
This provider is enabled by default in the STORAGE_PROVIDERS
config.
If you need to override this default, make sure to include AmazonS3Provider.
For example:
STORAGE_PROVIDERS = [
'sams.storage.providers.amazon.AmazonS3Provider'
]
This will then allow destinations to be configured for Sets to use. For example:
STORAGE_DESTINATION_1 = 'AmazonS3,Default,access=access123,secret=secret456,region=eu-west-3,bucket=test'
The following is a list of the supported config attributes
Attribute Name |
Description |
---|---|
access* |
Access key ID for authentication |
secret* |
Secret key for authentication |
region* |
Amazon region to use |
bucket* |
The name of the bucket to use |
endpoint_url |
The Amazon endpoint url |
folder |
An optional folder to use |
[*] Indicates required config attributes
-
class
AmazonS3Provider
(config_str: str)¶ Provides storage to/from Amazon S3
- Variables
_config (AmazonS3Config) – The S3 config
_client (boto3.client) – The Amazon client instance
type_name (str) – The type name used to identify this provider -
AmazonS3
-
exists
(media_id: str) → bool¶ Checks if a file exists in S3
- Params str media_id
The media_id from the Asset
- Returns
True
if a matching file exists,False
otherwise- Return type
-
put
(content: Union[BinaryIO, bytes], filename: str, mimetype: Optional[str] = None) → str¶ Upload a file to S3
-
get
(media_id: str) → superdesk.storage.amazon_media_storage.AmazonObjectWrapper¶ Get Asset binary from S3
- Parameters
media_id (str) – The media_id of the Asset
- Returns
A file-like object providing a
read()
method- Return type
AmazonObjectWrapper
-
drop
()¶ Deletes all assets from the S3 bucket/folder
-
get_all_keys_in_batches
()¶ Returns all the keys for a bucket/folder
-
create_bucket
()¶ Creates a new bucket in the S3 region
The name of the bucket is from the
STORAGE_DESTINATION
entry for this provider