1 defmodule Pleroma.Uploaders.Uploader do
3 Defines the contract to put and get an uploaded file to any backend.
7 Instructs how to get the file from the backend.
9 Used by `Pleroma.Plugs.UploadedMedia`.
11 @type get_method :: {:static_dir, directory :: String.t()} | {:url, url :: String.t()}
12 @callback get_file(file :: String.t()) :: {:ok, get_method()}
15 Put a file to the backend.
19 * `{:ok, spec}` where spec is:
20 * `{:file, filename :: String.t}` to handle reads with `get_file/1` (recommended)
22 This allows to correctly proxy or redirect requests to the backend, while allowing to migrate backends without breaking any URL.
24 * `{url, url :: String.t}` to bypass `get_file/2` and use the `url` directly in the activity.
25 * `{:error, String.t}` error information if the file failed to be saved to the backend.
32 content_type :: String.t(),
34 ) :: {:ok, {:file, String.t()} | {:url, String.t()}} | {:error, String.t()}