ChoreRunner.Downloads.StorageService behaviour (chore_runner v0.5.2)

Summary

Types

Must have the appropriate file extension to be considered a valid name.

While both :path and :body are optional, at least one is required. The application will raise if both are provided.

Functions

See ChoreRunner.Downloads.TemporaryDiskStorageService.delete_file/1.

See ChoreRunner.Downloads.TemporaryDiskStorageService.file_url/2.

See ChoreRunner.Downloads.TemporaryDiskStorageService.list_files/0.

Types

body()

@type body() :: binary()

file()

@type file() :: %{
  :id => String.t(),
  :name => String.t(),
  :type => String.t(),
  :created_at => DateTime.t(),
  optional(:chore_id) => String.t(),
  optional(atom()) => any()
}

file_path()

@type file_path() :: String.t()

name()

@type name() :: String.t()

Must have the appropriate file extension to be considered a valid name.

opts()

@type opts() :: [path: file_path(), body: body()]

While both :path and :body are optional, at least one is required. The application will raise if both are provided.

reason()

@type reason() :: any()

Callbacks

delete_file(file)

@callback delete_file(file()) :: :ok | {:error, reason()}

file_url(file, list)

@callback file_url(file(), list()) :: String.t()

list_files()

@callback list_files() :: {:ok, [file()]} | {:error, reason()}

save_file(name, opts)

@callback save_file(name(), opts()) :: {:ok, file()} | {:error, reason()}

Functions

delete_file(file)

See ChoreRunner.Downloads.TemporaryDiskStorageService.delete_file/1.

file_url(file, opts)

See ChoreRunner.Downloads.TemporaryDiskStorageService.file_url/2.

find_file(id)

find_files_by_chore_id(chore_id)

list_files()

See ChoreRunner.Downloads.TemporaryDiskStorageService.list_files/0.

save_file(name, opts)