Amarula.Content.Media (amarula v0.4.2)
View SourceA received media attachment (content of a %Amarula.Msg{type: :media}) — an
inbound image / video / audio / document / sticker. A plain snake_case struct,
not the raw protobuf. Pass it (or the whole %Amarula.Msg{}) to
Amarula.download_media/1 to fetch and decrypt the bytes — no live connection
needed; the keys ride in this struct.
Fields
:kind—:image | :video | :audio | :document | :sticker.:mimetype— the content type (e.g."image/jpeg","video/mp4","image/webp"for a sticker). Use this for the file extension /<img>vs<video>, not:kind— WhatsApp sends webp stickers, mp4 "gifs", etc.:caption— text shown with the media (nilif none).:file_length— size in bytes (nilif absent).:width/:height— pixel dimensions for image/video/sticker (nilotherwise).:seconds— duration for audio/video (nilotherwise).:file_name— original file name for documents (nilotherwise).
The remaining fields (:url, :direct_path, :media_key, :file_sha256,
:file_enc_sha256) are the CDN locator + decryption material used by
download_media; you rarely read them directly.
Summary
Functions
Normalize a raw media proto (%Proto.Message.ImageMessage{} etc.) into a
%Amarula.Content.Media{}. kind says which proto it is — several distinct media
protos map to this one struct, so the kind can't be recovered from the proto
alone. Snake-cases the camelCase fields and surfaces the type-relevant metadata;
missing fields are nil.
Types
@type kind() :: :image | :video | :audio | :document | :sticker
@type t() :: %Amarula.Content.Media{ caption: String.t() | nil, direct_path: String.t() | nil, file_enc_sha256: binary() | nil, file_length: non_neg_integer() | nil, file_name: String.t() | nil, file_sha256: binary() | nil, height: non_neg_integer() | nil, kind: kind(), media_key: binary() | nil, mimetype: String.t() | nil, seconds: non_neg_integer() | nil, url: String.t() | nil, width: non_neg_integer() | nil }
Functions
Normalize a raw media proto (%Proto.Message.ImageMessage{} etc.) into a
%Amarula.Content.Media{}. kind says which proto it is — several distinct media
protos map to this one struct, so the kind can't be recovered from the proto
alone. Snake-cases the camelCase fields and surfaces the type-relevant metadata;
missing fields are nil.