Capsule v1.0.0 Capsule.Storage behaviour View Source

Defines the behaviour for storage backends.

Implement this behaviour to create a storage adapter that can read, write, stream, and delete files.

Link to this section Summary

Link to this section Types

Specs

error() :: {:error, String.t()}

Specs

locator_id() :: String.t()

Specs

option() :: {atom(), any()}

Link to this section Callbacks

Specs

delete(locator_id()) :: :ok | error()
Link to this callback

delete(locator_id, list)

View Source

Specs

delete(locator_id(), [option()]) :: :ok | error()

Specs

put(Capsule.Upload.t()) :: {:ok, locator_id()} | error()

Specs

put(Capsule.Upload.t(), [option()]) :: {:ok, locator_id()} | error()

Specs

read(locator_id()) :: {:ok, binary()} | error()

Specs

read(locator_id(), [option()]) :: {:ok, binary()} | error()

Specs

stream!(locator_id()) :: Enumerable.t()
Link to this callback

stream!(locator_id, list)

View Source

Specs

stream!(locator_id(), [option()]) :: Enumerable.t()