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 option() :: {atom(), any()}
@type storage() :: atom()

Callbacks

Link to this callback

build_metadata(t, storage, list)

View Source
@callback build_metadata(Entrepot.Locator.t(), storage(), [option()]) ::
  Keyword.t() | map()

Builds metadata for the stored file.

Parameters

  • locator: The Locator 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.
Link to this callback

build_options(any, storage, list)

View Source
@callback build_options(any(), storage(), [option()]) :: [option()]

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.
Link to this callback

store(any, storage, list)

View Source
@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()}: A Locator struct representing the stored file.
  • {:error, any()}: An error tuple if the storage operation fails.