Skip to content

angee.storage.backends

Storage backend protocol and the bundled filesystem backend.

A backend is Django's Storage plus a presigned-download hook. Uploads follow one client protocol regardless of backend kind: begin reserves a File row and answers with a single upload_url, the client sends one raw PUT, and finalize verifies the bytes. Today every upload proxies through the server; a backend that can presign uploads natively (S3-style) is the follow-up that adds a presigned_put hook and the "presigned" method arm beside it.

Backend rows (storage.Backend) name a subclass of :class:StorageBackend by a key in ANGEE_STORAGE_BACKEND_CLASSES and carry its constructor config; resolution and caching live on the model that owns the row. This module stays ORM-free.

DOWNLOAD_URL_TTL_SECONDS

Lifetime requested for presigned download URLs.

StorageBackend

python
class StorageBackend(Storage)

Django Storage augmented with the storage addon's hooks.

Subclasses implement Django's existing surface (_save, _open, delete, exists, url, size) plus the hooks below. Backends do not implement authorization, byte hashing, or upload state; those live on File.objects and the REBAC schema.

__init__

python
def __init__(*, backend_config: Mapping[str, Any] | None = None) -> None

Store the resolved per-row backend config.

presigned_get

python
def presigned_get(key: str, *, expires_in: int) -> str | None

Return a time-limited download URL, or None to use url(key).

discard

python
def discard(key: str, *, context: str) -> None

Best-effort delete that logs transport failures instead of raising.

Cleanup paths (rejected uploads, dedup losers, purge) must not fail the surrounding state transition; a failed delete leaves an accepted orphan object behind.

LocalBackend

python
class LocalBackend(FileSystemStorage, StorageBackend)

Filesystem backend for development and small deployments.

Reads root and base_url from the owning Backend row's config, defaulting to Django's MEDIA_ROOT / MEDIA_URL.

__init__

python
def __init__(*, backend_config: Mapping[str, Any] | None = None) -> None

Bind the filesystem location and public base URL.

Directories are created lazily by FileSystemStorage on save.

Released under the AGPL-3.0 License.