ExWapp.Media.HTTP (ExWapp v0.1.2)

Copy Markdown View Source

Minimal WhatsApp media upload/download client.

The session worker supplies IQ access through opts[:session]; this module queries media_conn, uploads encrypted media bodies, and downloads encrypted bodies that are later verified and decrypted by ExWapp.Media.Crypto.

Summary

Functions

Downloads encrypted media and returns the decrypted plaintext bytes.

Encrypts plaintext media and uploads it to the best available media host.

Functions

download(state, ref, opts \\ [])

@spec download(map(), ExWapp.Media.Ref.t(), keyword()) ::
  {:ok, binary()} | {:error, term()}

Downloads encrypted media and returns the decrypted plaintext bytes.

upload(state, type, plaintext, opts \\ [])

@spec upload(map(), ExWapp.Media.media_type(), binary(), keyword()) ::
  {:ok, ExWapp.Media.Upload.t()} | {:error, term()}

Encrypts plaintext media and uploads it to the best available media host.