Karta. Messaging. MediaStore
(Karta v1.0.0)
Media of messages: the bytes in Karta.Storage (messaging/media/<id>,
AES-256-GCM per object), a row that says what they are
(Karta.Messaging.Media). Two ways in: an agent uploads a received file
before the event that names it (put_from_agent/6), and an application
uploads a file to send (put/5, POST /messaging/v1/media). Both are
limited to 16777216 bytes.
Summary
Functions
A file of the server by its public id, or nil.
The kind of a media type: image, video, audio or document.
The largest file in bytes.
A new public id: med_ and 28 hex digits.
Stores a file an application uploads to send; returns the media with its new ref.
Stores the file an agent uploaded under the id it made. Idempotent for
the same bytes: {:ok, media}; the same id with other bytes is
{:error, :conflict}; over the limit {:error, :too_large}; a hash that
does not match {:error, :bad_hash}.
The decrypted bytes of a file.
Files of a server older than before that no message holds (for tests and retention).
Functions
@spec get(Karta.Servers.Server.t() | Ecto.UUID.t(), String.t()) :: Karta.Messaging.Media.t() | nil
A file of the server by its public id, or nil.
The kind of a media type: image, video, audio or document.
The largest file in bytes.
@spec new_ref() :: String.t()
A new public id: med_ and 28 hex digits.
@spec put(Karta.Servers.Server.t(), String.t(), String.t() | nil, binary(), keyword()) :: {:ok, Karta.Messaging.Media.t()} | {:error, :too_large | :invalid | term()}
Stores a file an application uploads to send; returns the media with its new ref.
@spec put_from_agent( Karta.Messaging.Connector.t(), String.t(), String.t(), binary(), String.t() | nil, keyword() ) :: {:ok, Karta.Messaging.Media.t()} | {:error, :conflict | :too_large | :bad_hash | :invalid | term()}
Stores the file an agent uploaded under the id it made. Idempotent for
the same bytes: {:ok, media}; the same id with other bytes is
{:error, :conflict}; over the limit {:error, :too_large}; a hash that
does not match {:error, :bad_hash}.
@spec read(Karta.Messaging.Media.t(), keyword()) :: {:ok, binary()} | {:error, term()}
The decrypted bytes of a file.
@spec unattached(Ecto.UUID.t(), DateTime.t()) :: Ecto.Query.t()
Files of a server older than before that no message holds (for tests and retention).