Storage.Services behaviour (PhoenixContribStorage v0.1.0)

View Source

Service abstraction for different storage backends.

Summary

Functions

Deletes a file using the specified service.

Retrieves a file using the specified service.

Stores a file using the specified service.

Generates a signed URL for a file using the specified service.

Generates a URL for a file using the specified service.

Callbacks

delete_file(key)

@callback delete_file(key :: String.t()) :: :ok | {:error, term()}

get_file(key)

@callback get_file(key :: String.t()) :: {:ok, binary()} | {:error, term()}

put_file(key, data)

@callback put_file(key :: String.t(), data :: binary() | %{path: String.t()}) ::
  :ok | {:error, term()}

signed_url(key, opts)

@callback signed_url(key :: String.t(), opts :: keyword()) ::
  {:ok, String.t()} | {:error, term()}

url(key, opts)

@callback url(key :: String.t(), opts :: keyword()) :: String.t()

Functions

delete_file(service_name, key)

Deletes a file using the specified service.

get_file(service_name, key)

Retrieves a file using the specified service.

put_file(service_name, key, data)

Stores a file using the specified service.

signed_url(service_name, key, opts \\ [])

Generates a signed URL for a file using the specified service.

url(service_name, key, opts \\ [])

Generates a URL for a file using the specified service.