Pleroma v1.1.9-10-g42f76306+dev Pleroma.Uploaders.Uploader behaviour View Source
Defines the contract to put and get an uploaded file to any backend.
Link to this section Summary
Link to this section Types
Link to this section Functions
Link to this function
put_file(uploader, upload)
View Sourceput_file(module(), Pleroma.Upload.t()) :: {:ok, file_spec()} | {:error, String.t()}
Link to this section Callbacks
Link to this callback
get_file(file)
View Sourceget_file(file :: String.t()) :: {:ok, get_method()}
Instructs how to get the file from the backend.
Used by Pleroma.Plugs.UploadedMedia
.
Link to this callback
http_callback(arg1, arg2)
View Source (optional)http_callback(Plug.Conn.t(), Map.t()) :: {:ok, Plug.Conn.t()} | {:ok, Plug.Conn.t(), file_spec()} | {:error, Plug.Conn.t(), String.t()}
Link to this callback
put_file(arg1)
View Sourceput_file(Pleroma.Upload.t()) :: :ok | {:ok, file_spec()} | {:error, String.t()} | :wait_callback
Put a file to the backend.
Returns:
:ok
which assumes{:ok, upload.path}
{:ok, spec}
where spec is:{:file, filename :: String.t}
to handle reads withget_file/1
(recommended)
This allows to correctly proxy or redirect requests to the backend, while allowing to migrate backends without breaking any URL.
{url, url :: String.t}
to bypassget_file/2
and use theurl
directly in the activity.{:error, String.t}
error information if the file failed to be saved to the backend.:wait_callback
will wait for an http post request at/api/pleroma/upload_callback/:upload_path
and call the uploader'shttp_callback/3
method.