Inttegro.Files (inttegro v0.2.0)

Copy Markdown View Source

Uploads files, reads their metadata, and delivers their original bytes.

Inttegro stores file metadata separately from binary contents. Uploads move through processing and safety checks before becoming available. create/3 accepts bytes, lookup/3 returns metadata, and contents/3 returns a %Inttegro.Files.Download{} without exposing storage provider credentials or object keys.

Upload and download

upload = %Inttegro.Files.CreateRequest{
  file_name: "receipt.pdf",
  bytes: File.read!("receipt.pdf"),
  purpose: "order_document"
}

{:ok, file} = Inttegro.Files.create(client, upload,
  idempotency_key: "receipt-order-123"
)

request = Inttegro.Files.ContentsRequest.new!(file_id: file.id)
{:ok, download} = Inttegro.Files.contents(client, request)
File.write!("downloaded-receipt.pdf", download.bytes)

See the Files guide for lifecycle, delivery, and deletion behavior.

Summary

Functions

Streams original file bytes for a file owned by the authorized application, or returns a 303 redirect to a short-lived signed delivery URL when delivery is redirect.

Upload a file to Inttegro for the authorized application. The request must be multipart form data and include a binary file part plus a purpose.

Tombstones a file and schedules backing-object cleanup when allowed by reference policy.

Retrieves metadata for one file owned by the authorized application.

Lists files for the authorized application, optionally filtered by purpose, status, and creation window.

Functions

contents(client, request, options \\ [])

Streams original file bytes for a file owned by the authorized application, or returns a 303 redirect to a short-lived signed delivery URL when delivery is redirect.

Parameters

Returns

Returns {:ok, Inttegro.Files.Download.t()} when Inttegro accepts and decodes the operation. Returns {:error, exception} for API, transport, or decoding failures. A successful API response can still describe an asynchronous resource that has not reached its terminal state.

Example

request = Inttegro.Files.ContentsRequest.new!(request_attributes)

case Inttegro.Files.contents(client, request) do
  {:ok, result} -> result
  {:error, error} -> {:error, error}
end

create(client, request, options \\ [])

Upload a file to Inttegro for the authorized application. The request must be multipart form data and include a binary file part plus a purpose.

Parameters

Returns

Returns {:ok, Inttegro.Files.File.t()} when Inttegro accepts and decodes the operation. Returns {:error, exception} for API, transport, or decoding failures. A successful API response can still describe an asynchronous resource that has not reached its terminal state.

Example

request = Inttegro.Files.CreateRequest.new!(request_attributes)

case Inttegro.Files.create(client, request) do
  {:ok, result} -> result
  {:error, error} -> {:error, error}
end

delete(client, request, options \\ [])

Tombstones a file and schedules backing-object cleanup when allowed by reference policy.

Parameters

Returns

Returns {:ok, Inttegro.Files.File.t()} when Inttegro accepts and decodes the operation. Returns {:error, exception} for API, transport, or decoding failures. A successful API response can still describe an asynchronous resource that has not reached its terminal state.

Example

request = Inttegro.Files.DeleteRequest.new!(request_attributes)

case Inttegro.Files.delete(client, request) do
  {:ok, result} -> result
  {:error, error} -> {:error, error}
end

lookup(client, request, options \\ [])

Retrieves metadata for one file owned by the authorized application.

Parameters

Returns

Returns {:ok, Inttegro.Files.File.t()} when Inttegro accepts and decodes the operation. Returns {:error, exception} for API, transport, or decoding failures. A successful API response can still describe an asynchronous resource that has not reached its terminal state.

Example

request = Inttegro.Files.LookupRequest.new!(request_attributes)

case Inttegro.Files.lookup(client, request) do
  {:ok, result} -> result
  {:error, error} -> {:error, error}
end

page(client, request, options \\ [])

Lists files for the authorized application, optionally filtered by purpose, status, and creation window.

Parameters

Returns

Returns {:ok, Inttegro.Files.Page.t()} when Inttegro accepts and decodes the operation. Returns {:error, exception} for API, transport, or decoding failures. A successful API response can still describe an asynchronous resource that has not reached its terminal state.

Example

request = Inttegro.Files.PageRequest.new!(request_attributes)

case Inttegro.Files.page(client, request) do
  {:ok, result} -> result
  {:error, error} -> {:error, error}
end