KapsoEx.Platform.Media (kapso_ex v0.1.0)

Copy Markdown View Source

Ingest media from a public URL so it can be sent in messages.

To upload bytes, use KapsoEx.WhatsApp.Media.upload/4.

Summary

Functions

Fetches source (a public URL) and uploads it to Meta for phone_number_id.

Functions

upload(client, phone_number_id, source, opts \\ [])

@spec upload(KapsoEx.Client.t(), String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, KapsoEx.Error.t()}

Fetches source (a public URL) and uploads it to Meta for phone_number_id.

Options

  • :delivery - "meta_media" (default, returns a media ID for messages) or "meta_resumable_asset" (returns a handle, for example for template headers or profile pictures).
  • :filename, :mime_type - override what is inferred from the URL.

Examples

{:ok, %{"data" => %{"target" => %{"media_id" => media_id}}}} =
  Platform.Media.upload(client, phone_number_id, "https://example.com/menu.pdf")