keepluggable.storage_file package

Module contents

Strategies for storing file payloads.

class keepluggable.storage_file.BasePayloadStorage(orchestrator: keepluggable.orchestrator.Orchestrator)[source]

Bases: object

Abstract base class ― formal interface for payload storage backends.

abstract delete(namespace: str, metadatas: Sequence[Dict[str, Any]]) None[source]

Delete many files within a namespace.

abstract get_reader(namespace: str, metadata: Dict[str, Any]) BinaryIO[source]

Return an open “file” object from which the payload can be read.

Otherwise, raise KeyError.

abstract get_url(namespace: str, metadata: Dict[str, Any], seconds: int = 3600, https: bool = True) str[source]

Return a URL for a certain stored file.

abstract put(namespace: str, metadata: Dict[str, Any], bytes_io: BinaryIO) None[source]

Store a file (bytes_io) inside namespace.

keepluggable.storage_file.get_extension(mime_type: str) str[source]

From a mime_type return a corresponding file extension, or empty.