SealSkin

S3Store

Objects in a bucket of an S3-compatible service, addressed path-style.

Requests are signed with AWS Signature Version 4. Conditional writes use If-Match and If-None-Match, which the service must honor.

Attributes

attributeendpoint
= endpoint.rstrip('/')
attributebucket
= bucket
attributeprefix
= prefix.strip('/') + '/' if prefix.strip('/') else ''
attributeaccess_key
= access_key
attributesecret_key
= secret_key
attributeregion
= region

Functions

constructor__init__(endpoint, bucket, prefix, access_key, secret_key, region='us-east-1', transport=None) -> None

Bind the store to a bucket.

paramendpointstr

Base URL of the service, https://s3.example.com.

parambucketstr

Bucket name.

paramprefixstr

Key prefix every object is kept under; may be empty.

paramaccess_keystr

Access key id.

paramsecret_keystr

Secret access key.

paramregionstr
= 'us-east-1'

Region the signature names.

paramtransporthttpx.BaseTransport | None
= None

Transport override for tests.

Returns

None
func_sign(method, path, query, headers, body) -> None

Add the Signature Version 4 headers for a request to headers.

parammethodstr
parampathstr
paramquerydict[str, str]
paramheadersdict[str, str]
parambodybytes

Returns

None
func_request(method, key, query=None, headers=None, body=b'') -> httpx.Response

Send a signed request for an object, or for the bucket when key is None.

parammethodstr
paramkeystr | None
paramquerydict[str, str] | None
= None
paramheadersdict[str, str] | None
= None
parambodybytes
= b''

Returns

httpx.httpx.Response
func_check(response, key) -> None

Raise for a refused condition or any other failure.

paramresponsehttpx.Response
paramkeystr

Returns

None
funcget(key) -> tuple[bytes, str] | None

Fetch an object.

paramkeystr

Returns

tuple[bytes, str] | None
funcput(key, data, if_match=None, if_absent=False) -> str

Upload an object, conditionally when asked.

paramkeystr
paramdatabytes
paramif_matchstr | None
= None
paramif_absentbool
= False

Returns

str
funcdelete(key, if_match=None) -> None

Delete an object, after comparing its entity tag when asked.

paramkeystr
paramif_matchstr | None
= None

Returns

None
funclist(prefix='') -> dict[str, str]

List the bucket under the store's prefix, following continuation tokens.

paramprefixstr
= ''

Returns

dict[str, str]