Object Store

Async object storage client for pyfetcher.store.

Purpose:

Provide an async client for MinIO/S3 operations: upload, download, delete, list, and presigned URL generation. Uses aioboto3 for async S3 compatibility.

class pyfetcher.store.client.ObjectStoreClient(config=None)[source]

Async object storage client for MinIO/S3.

Provides upload, download, delete, and presigned URL operations using aioboto3’s async S3 interface against a MinIO endpoint.

Parameters:

config (PyfetcherConfig | None) – Application configuration with MinIO connection details.

async ensure_bucket(bucket=None)[source]

Create the bucket if it doesn’t exist.

Parameters:

bucket (str | None) – Bucket name. Defaults to config bucket.

Return type:

None

async upload_bytes(key, data, *, bucket=None, content_type=None)[source]

Upload bytes to object storage.

Parameters:
  • key (str) – Object key.

  • data (bytes) – Bytes to upload.

  • bucket (str | None) – Bucket name. Defaults to config bucket.

  • content_type (str | None) – Optional MIME type.

Returns:

The object key.

Return type:

str

async upload_file(key, file_path, *, bucket=None, content_type=None)[source]

Upload a local file to object storage.

Parameters:
  • key (str) – Object key.

  • file_path (str | Path) – Local file path.

  • bucket (str | None) – Bucket name. Defaults to config bucket.

  • content_type (str | None) – Optional MIME type.

Returns:

The object key.

Return type:

str

async download_bytes(key, *, bucket=None)[source]

Download an object as bytes.

Parameters:
  • key (str) – Object key.

  • bucket (str | None) – Bucket name. Defaults to config bucket.

Returns:

The object contents as bytes.

Return type:

bytes

async presigned_get_url(key, *, bucket=None, expires_in=3600)[source]

Generate a presigned GET URL.

Parameters:
  • key (str) – Object key.

  • bucket (str | None) – Bucket name. Defaults to config bucket.

  • expires_in (int) – URL expiration in seconds.

Returns:

A presigned URL string.

Return type:

str

async delete(key, *, bucket=None)[source]

Delete an object.

Parameters:
  • key (str) – Object key.

  • bucket (str | None) – Bucket name. Defaults to config bucket.

Return type:

None

async list_keys(prefix='', *, bucket=None, max_keys=1000)[source]

List object keys under a prefix.

Parameters:
  • prefix (str) – Key prefix filter.

  • bucket (str | None) – Bucket name. Defaults to config bucket.

  • max_keys (int) – Maximum keys to return.

Returns:

A list of matching object keys.

Return type:

list[str]