Rindle.Profile (Rindle v0.1.5)

Copy Markdown View Source

Profile DSL used to declare upload policy and variant recipes.

Profiles are validated at compile time so invalid configuration fails fast before runtime upload and processing flows execute.

Summary

Functions

Declares a Rindle profile.

Types

variant_entry()

@type variant_entry() :: {atom(), variant_spec()}

variant_spec()

@type variant_spec() :: %{required(atom()) => term()}

Functions

__using__(opts)

(macro)
@spec __using__(keyword()) :: Macro.t()

Declares a Rindle profile.

When used, this macro validates the supplied options at compile time and generates the storage_adapter/0, variants/0, upload_policy/0, validate_upload/1, delivery_policy/0, and recipe_digest/1 functions that the rest of Rindle dispatches through.

Example

defmodule MyApp.AvatarProfile do
  use Rindle.Profile,
    storage: Rindle.Storage.S3,
    allow_mime: ["image/png", "image/jpeg"],
    max_bytes: 10_000_000,
    delivery: %{public: false, signed_url_ttl_seconds: 900},
    variants: %{thumb: %{width: 128, height: 128, format: :webp}}
end