Skip to content

Base

Base class for object storage clients.

Authors

Fachriza Adhiatma (fachriza.d.adhiatma@gdplabs.id) Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)

BaseObjectStorageClient

Bases: ABC

Abstract base class for object storage clients.

delete(object_key) abstractmethod

Delete data from object storage.

Parameters:

Name Type Description Default
object_key str

The key of the object in the storage

required

generate_presigned_url(object_key, expires=24, response_headers=None) abstractmethod

Generate a presigned URL for accessing the object.

Parameters:

Name Type Description Default
object_key str

The key of the object in the storage

required
expires int

The number of hours the URL is valid for

24
response_headers dict[str, str] | None

Additional headers to include in the response

None

Returns:

Type Description
str

The presigned URL

get(object_key) abstractmethod

Get data from object storage.

Parameters:

Name Type Description Default
object_key str

The key of the object in the storage

required

Returns:

Type Description
bytes

The binary data of the object

object_exists(object_key) abstractmethod

Check if an object exists in the storage.

Parameters:

Name Type Description Default
object_key str

The key of the object to check.

required

Returns:

Type Description
bool

True if the object exists, False otherwise.

upload(object_key, file_stream, filename=None, content_type=None, metadata=None) abstractmethod

Upload data to object storage.

Parameters:

Name Type Description Default
object_key str

The key of the object in the storage

required
file_stream bytes | BinaryIO

The binary data to upload

required
filename str | None

The name of the file

None
content_type str | None

The content type of the file

None
metadata dict[str, str] | None

Additional metadata to store with the object

None

Returns:

Type Description
str

The key of the uploaded object