View Source Entrepot.Uploader behaviour (Bonfire v0.9.10-classic-beta.169)
A behaviour module for implementing custom uploaders.
This module provides a set of callbacks and a macro for easily defining uploaders that work with different storage backends.
Summary
Callbacks
Builds metadata for the stored file.
Builds options for the storage operation.
Stores an upload in the specified storage.
Types
@type storage() :: atom()
Callbacks
@callback build_metadata(Entrepot.Locator.t(), storage(), [option()]) :: Keyword.t() | map()
Builds metadata for the stored file.
Parameters
locator
: TheLocator
struct representing the stored file.storage
: The storage backend used.opts
: The options used in the storage operation.
Returns
- A keyword list or map of metadata to be added to the
Locator
.
Builds options for the storage operation.
Parameters
upload
: The upload to be stored.storage
: The storage backend to use.opts
: Initial list of options.
Returns
- A list of options to be used in the storage operation.
@callback store(any(), storage(), [option()]) :: {:ok, Entrepot.Locator.t()} | {:error, any()}
Stores an upload in the specified storage.
Parameters
upload
: The upload to be stored.storage
: The storage backend to use.opts
: Optional list of options for the storage operation.
Returns
{:ok, Locator.t()}
: ALocator
struct representing the stored file.{:error, any()}
: An error tuple if the storage operation fails.