Uploader v0.1.0 Uploader.LocalUploader View Source
Store file uploads locally. This module implements the maybe_copy_file/4
callback
function defined in the Uploader
module.
Link to this section Summary
Functions
Copies the uploaded file to a given new file path.
Link to this section Functions
maybe_copy_file(tmp_file_path, new_file_path, on_file_exists \\ nil)
View SourceCopies the uploaded file to a given new file path.
The third optional argument on_file_exists
allows to specify what should
happen in case the filename already exists. If no value is given and the filename
already exists, the file is not copied and an error is returned. This behaviour
may be changed by setting the value to:
:overwrite
: overwrite the file if the file path already exists.:compare_hash
: do not copy the file if the file path already exists; if the hashes of the files' content are not equal, return an error.
This function returns :ok
in case of success. If an error occurs, a two-elements
tuple is returned with the first element being :error
and the second element another
two-elements tuple describing the type of error and a value. For example:
{:error, {:file_path_exists, file_path}}
.