Coffrify.Resources.Transfers (Coffrify v0.9.0)

View Source

Transfers — Coffrify's core file-sharing primitive.

Server-side mode: the SDK creates a transfer record and returns presigned upload URLs. Clients PUT ciphertext directly to those URLs. The Coffrify API never sees plaintext.

Summary

Functions

Duplicate a transfer with a fresh short_code and reset download counter.

Create a transfer (server-side upload). Files must be uploaded separately to the returned signed URLs.

Delete a transfer.

Fetch a single transfer by id.

Lazy Stream over every transfer. Cursor-paginated under the hood.

List transfers (cursor-paginated). See iterate/2 for a lazy stream.

Return the share URL + a QR-code proxy URL.

Re-queue the AV scan for a transfer (sets scan_status=pending).

Assign or unfile (nil) this transfer to a folder.

Types

create_opts()

@type create_opts() :: %{
  optional(:expires_in_hours) => pos_integer(),
  optional(:max_downloads) => pos_integer(),
  optional(:password) => String.t(),
  optional(:notify_email) => String.t(),
  optional(:custom_slug) => String.t(),
  optional(:transfer_title) => String.t(),
  optional(:transfer_message) => String.t()
}

file_input()

@type file_input() :: %{
  :name => String.t(),
  :size => non_neg_integer(),
  optional(:mime_type) => String.t()
}

list_opts()

@type list_opts() :: [
  limit: pos_integer(),
  cursor: String.t() | nil,
  offset: non_neg_integer(),
  status: String.t()
]

Functions

clone(client, transfer_id, opts \\ %{})

@spec clone(Coffrify.t(), String.t(), map() | keyword()) ::
  {:ok, map()} | {:error, Exception.t()}

Duplicate a transfer with a fresh short_code and reset download counter.

create(client, files, options \\ %{})

@spec create(Coffrify.t(), [file_input()], create_opts()) ::
  {:ok, map()} | {:error, Exception.t()}

Create a transfer (server-side upload). Files must be uploaded separately to the returned signed URLs.

delete(client, transfer_id)

@spec delete(Coffrify.t(), String.t()) :: {:ok, map()} | {:error, Exception.t()}

Delete a transfer.

get(client, transfer_id)

@spec get(Coffrify.t(), String.t()) :: {:ok, map()} | {:error, Exception.t()}

Fetch a single transfer by id.

iterate(client, opts \\ [])

@spec iterate(
  Coffrify.t(),
  keyword()
) :: Enumerable.t()

Lazy Stream over every transfer. Cursor-paginated under the hood.

Example

client
|> Coffrify.Resources.Transfers.iterate(page_size: 100, status: "active")
|> Stream.take(500)
|> Enum.each(&IO.inspect/1)

list(client, opts \\ [])

@spec list(Coffrify.t(), list_opts()) :: {:ok, map()} | {:error, Exception.t()}

List transfers (cursor-paginated). See iterate/2 for a lazy stream.

qrcode(client, transfer_id, opts \\ [])

@spec qrcode(Coffrify.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Exception.t()}

Return the share URL + a QR-code proxy URL.

rescan(client, transfer_id)

@spec rescan(Coffrify.t(), String.t()) :: {:ok, map()} | {:error, Exception.t()}

Re-queue the AV scan for a transfer (sets scan_status=pending).

set_folder(client, transfer_id, folder_id)

@spec set_folder(Coffrify.t(), String.t(), String.t() | nil) ::
  {:ok, map()} | {:error, Exception.t()}

Assign or unfile (nil) this transfer to a folder.