Rindle.Domain.MediaUploadSession (Rindle v0.1.5)

Copy Markdown View Source

Ecto schema for a direct upload session.

A MediaUploadSession tracks the lifecycle of a direct-to-storage upload — from the moment Rindle issues a presigned PUT URL through verification of the uploaded object.

States

StateMeaning
"initialized"Session created; no presigned URL yet.
"signed"Presigned PUT URL issued to client.
"uploading"Client has begun (or is presumed to have begun) the PUT.
"uploaded"Storage reports the object exists at the expected key.
"verifying"Server-side validation (MIME, size) in progress.
"completed"Verification passed; asset promoted.
"aborted"Client cancelled or server rejected.
"expired"TTL elapsed before completion.
"failed"Verification failed (MIME mismatch, size limit, scanner).

See the state table below for the supported transitions and Rindle.Upload.Broker for the lifecycle entry points.

Summary

Functions

Builds a changeset for an upload-session row.

Types

t()

@type t() :: %Rindle.Domain.MediaUploadSession{
  __meta__: term(),
  asset: term(),
  asset_id: term(),
  expires_at: term(),
  failure_reason: term(),
  id: term(),
  inserted_at: term(),
  last_known_offset: term(),
  multipart_parts: term(),
  multipart_upload_id: term(),
  region_hint: term(),
  session_uri: term(),
  session_uri_expires_at: term(),
  state: term(),
  updated_at: term(),
  upload_key: term(),
  upload_strategy: term(),
  verified_at: term()
}

Functions

changeset(upload_session, attrs)

@spec changeset(
  t()
  | %Rindle.Domain.MediaUploadSession{
      __meta__: term(),
      asset: term(),
      asset_id: term(),
      expires_at: term(),
      failure_reason: term(),
      id: term(),
      inserted_at: term(),
      last_known_offset: term(),
      multipart_parts: term(),
      multipart_upload_id: term(),
      region_hint: term(),
      session_uri: term(),
      session_uri_expires_at: term(),
      state: term(),
      updated_at: term(),
      upload_key: term(),
      upload_strategy: term(),
      verified_at: term()
    },
  map()
) :: Ecto.Changeset.t()

Builds a changeset for an upload-session row.

Casts the lifecycle, multipart, and verification columns; requires the minimum invariants (:asset_id, :state, :upload_key, :upload_strategy, :expires_at); validates the lifecycle state against the canonical state list.

redact_session_uri(session_uri)

@spec redact_session_uri(nil | String.t()) :: nil | String.t()