View Source IVCU (IVCU v0.1.1)
Provides an API to validate, convert, and save files to abstract storages.
usage
Usage
Suppose you have a definition MyApp.Image
.
Then you can save a file from Plug.Upload
struct like this.
def save(%Plug.Upload{path: path}) do
path
|> IVCU.File.from_path()
|> IVCU.save(MyApp.Image)
end
See Getting Started guide for more information.
Link to this section Summary
Functions
Delete files from the storage.
Save the file with provided definition.
Return urls to access all the versions of the file in the storage.
Link to this section Functions
Specs
delete(IVCU.File.t(), module()) :: :ok | {:error, term()}
Delete files from the storage.
algorithm
Algorithm
- generate filenames for versions specified in the
definition
module; - delete the files from the storage.
Note
definition
must implement Definition behaviour.
Specs
save(IVCU.File.t(), module()) :: {:ok, [IVCU.File.t()]} | {:error, term()}
Save the file with provided definition.
algorithm
Algorithm
- validate the original file;
- generate new filenames;
- apply transformations to the file providing new filenames;
- put the new files in the storage.
Note
definition
must implement Definition behaviour.
Note
Expected order of files is the same as order in which versions were provided in the
definition
.
Specs
urls(IVCU.File.t(), module()) :: %{required(atom()) => url} when url: String.t()
Return urls to access all the versions of the file in the storage.
Note
definition
must implement Definition behaviour.