Skip to content

gufo.blob.sync.file

FileBlob implementation.

FileBlob

Bases: BlobBase

Filesystem-backed blob store.

Stores binary objects on local filesystem under a fixed root directory.

The API exposes a flat keyspace model. There are no directories in the logical model, only keys.

All operations are sandboxed to prevent escaping the root directory via path traversal or absolute paths.

delete(key)

Delete key.

Parameters:

Name Type Description Default
key str

Object key.

required

Raises:

Type Description
KeyError

If the key does not exist.

BlobError

On backend or I/O failure.

exists(key)

Check whether a key exists in the blob store.

Parameters:

Name Type Description Default
key str

Object key.

required

Returns:

Type Description
bool

True if the key exists, False otherwise.

Raises:

Type Description
BlobError

On backend or I/O failure.

get(key)

Retrieve data by key.

Parameters:

Name Type Description Default
key str

Object key.

required

Raises:

Type Description
BlobError

On backend or I/O failure.

parse_url(url) classmethod

Parse URL and extract parameters for constructor.

Parameters:

Name Type Description Default
url str

URL to parse.

required

Returns:

Type Description
dict[str, Any]

**kwargs for constructor.

put(key, data)

Store binary data under the given key.

If the key already exists, its value is overwritten.

Parameters:

Name Type Description Default
key str

Object key.

required
data bytes

Binary payload.

required

Raises:

Type Description
BlobError

On backend or I/O failure.

scan(prefix)

Iterate all keys within prefix.

Parameters:

Name Type Description Default
prefix str

Prefix to scan.

required

Returns:

Type Description
Iterable[str]

Yields matched keys.

Raises:

Type Description
BlobError

On backend or I/O failure.