Capsule v1.0.0 Capsule.Locator View Source

A struct that identifies an uploaded file by its storage location.

Contains the file's ID within the storage backend, the storage module, and arbitrary metadata.

Link to this section Summary

Functions

Creates a new Capsule.Locator from the given attributes. Returns {:ok, locator} on success or {:error, reason} on failure.

Same as new/1, but raises Capsule.Errors.InvalidLocator instead of returning an error tuple.

Link to this section Types

Specs

t() :: %Capsule.Locator{id: String.t(), metadata: map(), storage: String.t()}

Link to this section Functions

Specs

new(keyword() | map()) :: {:ok, t()} | {:error, String.t()}

Creates a new Capsule.Locator from the given attributes. Returns {:ok, locator} on success or {:error, reason} on failure.

Accepts a keyword list or map with :id and :storage keys, or string keys "id" and "storage".

Specs

new!(keyword() | map()) :: t()

Same as new/1, but raises Capsule.Errors.InvalidLocator instead of returning an error tuple.