View Source Tempel.Gate behaviour (Tempel v0.2.0)

Summary

Provides macros to creates uploader modules

defmodule MyUploader do
  service(persistence: Tempel.Local, variant: Tempel.Variant)
end

Available types:

  • file() is structured to match the format of Plug.Upload
  • fileio() is structured like file(). But instead of the file path it contains the IO data in key :iodata

Link to this section Summary

Types

This type is stuctured like the format of Plug.Upload

fileio() is structured like file(). But instead of the file path it contains the IO data in key :iodata mainly the result from variant generation in Tempel.Variant

This type is the one will be consumed to Tempel.Local

This type is the retun after save from Tempel.Local through Tempel.Persistence

Callbacks

This function is used to initialize the settings, could be storage path, aws secret key, etc.

Link to this section Types

@type file() :: %{filename: String.t(), path: String.t(), content_type: String.t()}

This type is stuctured like the format of Plug.Upload

@type fileio() :: %{iodata: binary(), path: String.t(), content_type: String.t()}

fileio() is structured like file(). But instead of the file path it contains the IO data in key :iodata mainly the result from variant generation in Tempel.Variant

@type raw_variant() :: %{required(name :: String.t()) => file() | fileio()}

This type is the one will be consumed to Tempel.Local

@type saved_variant() :: %{required(name :: String.t()) => object_key :: String.t()}

This type is the retun after save from Tempel.Local through Tempel.Persistence

Link to this section Callbacks

@callback init(opts :: term()) :: term()

This function is used to initialize the settings, could be storage path, aws secret key, etc.

Link to this callback

pipeline(name, files, opts)

View Source
@callback pipeline(name :: atom(), files :: [file()], opts :: keyword()) :: raw_variant()

Link to this section Functions

Link to this function

create_variants(formatted_images, options \\ [])

View Source
@spec format_files(files :: [file()]) :: [file()]
@spec format_files(file :: file()) :: term()
Link to this function

no_variants(files, options \\ [])

View Source
Link to this function

write_option(variant_option, file)

View Source