Uploadex v3.0.0-rc.1 Uploadex.Files View Source

Functions to store and delete files.

Note that all functions in this module require the Uploader as an argument. You are free to call them like that:

iex> Uploadex.Files.store_files(user, MyUploader)
{:ok, %User{}}

However, by doing use Uploadex in your uploader, you can call these functions directly through the uploader to avoid having to pass this extra argument around:

iex> MyUploader.store_files(user)
{:ok, %User{}}

Link to this section Summary

Link to this section Types

Link to this type

record_field()

View Source
record_field() :: atom()
Link to this type

status()

View Source
status() :: :ok | :error

Link to this section Functions

Link to this function

delete_files(record, uploader)

View Source
delete_files(record(), Uploadex.Uploader.t()) ::
  {:ok, record()} | {:error, any()}

Deletes all files for a record.

Link to this function

delete_previous_files(new_record, previous_record, uploader)

View Source
delete_previous_files(record(), record(), Uploadex.Uploader.t()) ::
  {:ok, record()} | {:error, any()}

Deletes all files that changed.

Link to this function

get_file_url(record, file, field, uploader)

View Source
get_file_url(record(), String.t(), record_field(), Uploadex.Uploader.t()) ::
  {status(), String.t() | nil}
Link to this function

get_files_url(record, field, uploader)

View Source
get_files_url(record(), record_field(), Uploadex.Uploader.t()) ::
  {status(), [String.t()]}
Link to this function

get_files_url(record, files, field, uploader)

View Source
get_files_url(
  record(),
  String.t() | [String.t()],
  record_field(),
  Uploadex.Uploader.t()
) :: {status(), [String.t()]}
Link to this function

get_temporary_file(record, file, path, field, uploader)

View Source
get_temporary_file(
  record(),
  String.t(),
  String.t(),
  record_field(),
  Uploadex.Uploader.t()
) :: String.t() | nil | {:error, String.t()}
Link to this function

get_temporary_files(record, path, field, uploader)

View Source
get_temporary_files(record(), String.t(), record_field(), Uploadex.Uploader.t()) ::
  [String.t()]
Link to this function

get_temporary_files(record, files, path, field, uploader)

View Source
get_temporary_files(
  record(),
  String.t() | [String.t()],
  String.t(),
  record_field(),
  Uploadex.Uploader.t()
) :: [String.t()]
Link to this function

store_files(record, uploader)

View Source
store_files(record(), Uploadex.Uploader.t()) ::
  {:ok, record()} | {:error, any()}

Stores all files of a record, as defined by the uploader.

Files that are not maps are ignored, which allows for assigning an existing file to a record without recreating it, by simply passing it's filename.