View Source Uploadex.Files (Uploadex v3.1.0)
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{}}
Summary
Functions
Deletes all files for a record.
Deletes all files that changed.
Stores all files of a record, as defined by the uploader.
Types
Functions
@spec delete_files(record(), Uploadex.Uploader.t()) :: {:ok, record()} | {:error, any()}
Deletes all files for a record.
@spec delete_previous_files(record(), record(), Uploadex.Uploader.t()) :: {:ok, record()} | {:error, any()}
Deletes all files that changed.
@spec get_file_url(record(), String.t(), record_field(), Uploadex.Uploader.t()) :: {status(), String.t() | nil}
@spec get_files_url(record(), record_field(), Uploadex.Uploader.t()) :: {status(), [String.t()]}
@spec get_files_url( record(), String.t() | [String.t()], record_field(), Uploadex.Uploader.t() ) :: {status(), [String.t()]}
@spec get_temporary_file( record(), String.t(), String.t(), record_field(), Uploadex.Uploader.t() ) :: String.t() | nil | {:error, String.t()}
@spec get_temporary_files(record(), String.t(), record_field(), Uploadex.Uploader.t()) :: [String.t()]
@spec get_temporary_files( record(), String.t() | [String.t()], String.t(), record_field(), Uploadex.Uploader.t() ) :: [String.t()]
@spec 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.
@spec store_files(record(), record(), Uploadex.Uploader.t()) :: {:ok, record()} | {:error, any()}