Download and decrypt WhatsApp CDN media referenced by media message structs.
Summary
Functions
Download and decrypt media referenced by a WhatsApp media message.
Download and decrypt media directly to a file path without buffering the full media body in memory.
Types
@type download_error() :: :missing_media_key | :missing_media_url | :unknown_media_type | :invalid_media_payload | :invalid_padding | {:http_error, pos_integer(), term()}
Functions
@spec download( media_message(), keyword() ) :: {:ok, binary()} | {:error, download_error()}
Download and decrypt media referenced by a WhatsApp media message.
Supports :start_byte and :end_byte options for Baileys-style ranged media
downloads. :end_byte is an exclusive upper bound.
The streamed path decrypts aligned AES-CBC chunks on the fly and does not
validate the trailing 10-byte media MAC. For full-payload MAC verification,
use BaileysEx.Media.Crypto.decrypt/3.
@spec download_to_file(media_message(), Path.t(), keyword()) :: {:ok, Path.t()} | {:error, download_error()}
Download and decrypt media directly to a file path without buffering the full media body in memory.
Like download/2, this uses chunked AES-CBC decryption and does not verify
the trailing media MAC while streaming.