View Source Dropkick.Uploader behaviour (dropkick v0.0.1)
Defines the behaviour for a file uploader.
Link to this section Summary
Callbacks
Process some logic after deleting a %Dropkick.File struct.
This function must return a success tuple with the file, otherwise the operation will fail.
When an error is returned, the file is still deleted, but the rest of the pipeline is aborted.
Process some logic after storing a %Dropkick.File struct.
This function must return a success tuple with the file, otherwise the operation will fail.
When an error is returned, the file is still stored, but the rest of the pipeline is aborted.
Process some logic before deleting a %Dropkick.File struct.
This function must return a success tuple with the file, otherwise the operation will fail.
When an error is returned, the delete operation won't be executed and the pipeline is aborted.
Process some logic before storing a %Dropkick.File struct.
This function must return a success tuple with the file, otherwise the store operation will fail.
When an error is returned, the store operation won't be executed and the pipeline is aborted.
Process some logic after storing/deleting a %Dropkick.File struct.
When a success tuple is returned, the value is simply logged into the terminal.
Whatever is executed inside this callback is completely isolated and doesn't affect the pipeline.
You can implement this callback to do any post-processing with without modifying the original file.
Returns the storage path for a given scope. This function can be used to personalize the directory where files are saved.
Link to this section Callbacks
@callback after_delete(Dropkick.File.t(), any()) :: {:ok, Dropkick.File.t()}
Process some logic after deleting a %Dropkick.File struct.
This function must return a success tuple with the file, otherwise the operation will fail.
When an error is returned, the file is still deleted, but the rest of the pipeline is aborted.
@callback after_store(Dropkick.File.t(), any()) :: {:ok, Dropkick.File.t()}
Process some logic after storing a %Dropkick.File struct.
This function must return a success tuple with the file, otherwise the operation will fail.
When an error is returned, the file is still stored, but the rest of the pipeline is aborted.
@callback before_delete(Dropkick.File.t(), any()) :: {:ok, Dropkick.File.t()}
Process some logic before deleting a %Dropkick.File struct.
This function must return a success tuple with the file, otherwise the operation will fail.
When an error is returned, the delete operation won't be executed and the pipeline is aborted.
@callback before_store(Dropkick.File.t(), any()) :: {:ok, Dropkick.File.t()}
Process some logic before storing a %Dropkick.File struct.
This function must return a success tuple with the file, otherwise the store operation will fail.
When an error is returned, the store operation won't be executed and the pipeline is aborted.
@callback process(Dropkick.File.t(), any()) :: {:ok, Dropkick.File.t()}
Process some logic after storing/deleting a %Dropkick.File struct.
When a success tuple is returned, the value is simply logged into the terminal.
Whatever is executed inside this callback is completely isolated and doesn't affect the pipeline.
You can implement this callback to do any post-processing with without modifying the original file.
Returns the storage path for a given scope. This function can be used to personalize the directory where files are saved.
example
Example
You can user pattern matching to specify multiple clauses:
def storage_prefix({store, :logo}), do: "avatars/#{user.id}"
def storage_prefix({user, :avatar}), do: "avatars/#{user.id}"
def storage_prefix({%{id: id}, _}), do: "files/#{id}"