Skip to content

gufo.blob.common.s3

Common S3 definitions and utilities.

S3Error

Parse error responses from S3-compatible API.

from_xml(body) classmethod

Parse S3 XML error response into a BlobError.

Parameters:

Name Type Description Default
body bytes

XML error body.

required

Returns:

Type Description
BlobError

BlobError with parsed message.

S3Info

Information about an S3-compatible service connection.

Attributes:

Name Type Description
host

Server hostname or address.

port

Server port.

bucket

Bucket name used for this connection.

prefix

Optional key prefix within the bucket.

access_key

AWS access key (optional).

secret_key

AWS secret key (optional).

endpoint property

Build the S3-compatible endpoint URL.

clone()

Return a shallow copy of this connection info.

Returns:

Type Description
S3Info

New S3Info with the same attributes.

url(*, prefix=None)

Build full connection URL for gufo.blob backends.

Parameters:

Name Type Description Default
prefix str | None

Override default key prefix.

None

S3Response

Bases: Protocol

Subset of an HTTP response used by the S3 backend.

content property

Return the response body.

status property

Return the HTTP status code.

S3Xml

Parse XML responses from S3-compatible API.

list_objects(body) classmethod

Parse ListObjectsV2 response.

Parameters:

Name Type Description Default
body bytes

XML body with object listings.

required

Returns:

Type Description
tuple[list[str], str | None]

Tuple of (list_of_keys, next_continuation_token_or_none).

Raises:

Type Description
BlobError

on malformed XML response.

parse_url(url)

Parse S3 URL and extract parameters for the constructor.

Accepts s3://bucket/path URLs with optional query params::

s3://mybucket/prefix?endpoint=http://127.0.0.1:5555&region=us-east-1

Parameters:

Name Type Description Default
url str

S3-compatible URL.

required

Returns:

Type Description
dict[str, Any]

**kwargs for the backend constructor.

Raises:

Type Description
BlobError

on unsupported schemas or missing bucket name.

sign_request(method, url, body, region, credentials)

Create SigV4 headers when credentials are configured.