TreasuryPrime.File (TreasuryPrime v1.0.0)

Copy Markdown View Source

Raw file storage, used as the building block for check deposit images (TreasuryPrime.CheckDeposit) and supporting KYC/KYB documentation (TreasuryPrime.Document).

Unlike every other resource, file upload doesn't take a JSON body — you POST the raw bytes with the appropriate Content-Type header.

Uploading

{:ok, file} = TreasuryPrime.File.upload(client, image_binary, "image/jpeg")
file.id #=> "file_..."

Downloading

{:ok, binary} = TreasuryPrime.File.download(client, file.id)
Elixir.File.write!("check_front.jpg", binary)

Summary

Functions

Downloads a file's raw binary content.

Fetches file metadata by id.

Uploads raw binary content (e.g. JPEG/PNG for check images, PDF for documents). Returns file metadata including the new id.

Types

t()

@type t() :: %TreasuryPrime.File{
  content_type: String.t() | nil,
  created_at: String.t() | nil,
  filename: String.t() | nil,
  id: String.t() | nil,
  size: integer() | nil,
  updated_at: String.t() | nil
}

Functions

download(client, id)

@spec download(TreasuryPrime.Client.t(), String.t()) ::
  {:ok, binary()} | {:error, TreasuryPrime.Error.t()}

Downloads a file's raw binary content.

download!(client, id)

@spec download!(TreasuryPrime.Client.t(), String.t()) :: binary()

get(client, id)

@spec get(TreasuryPrime.Client.t(), String.t()) ::
  {:ok, t()} | {:error, TreasuryPrime.Error.t()}

Fetches file metadata by id.

get!(client, id)

@spec get!(TreasuryPrime.Client.t(), String.t()) :: t()

upload(client, binary, content_type)

@spec upload(TreasuryPrime.Client.t(), binary(), String.t()) ::
  {:ok, t()} | {:error, TreasuryPrime.Error.t()}

Uploads raw binary content (e.g. JPEG/PNG for check images, PDF for documents). Returns file metadata including the new id.

upload!(client, binary, content_type)

@spec upload!(TreasuryPrime.Client.t(), binary(), String.t()) :: t()