FoPost.Media (FoPost v0.1.0)

Copy Markdown View Source

The media library.

Uploads count against the plan's storage allowance and are reachable with the posts scope. Up to five files per call, 50 MB each; the API verifies the bytes against the declared type.

{:ok, [asset]} =
  FoPost.Media.upload(client, workspace_id: workspace.id, files: ["chart.png"])

FoPost.Posts.create(client,
  workspace_id: workspace.id,
  accounts: [account.id],
  content: %{text: "The numbers", media: [FoPost.MediaAsset.to_media_item(asset)]}
)

A file is a path, a {filename, content} tuple, or a map of :filename, :content, and optionally :content_type.

Summary

Functions

Removes an asset from the library.

A workspace's media library. :workspace_id is required.

Stores files in the media library.

Functions

delete(client, id)

@spec delete(FoPost.Client.t(), String.t()) ::
  {:ok, FoPost.Message.t()} | {:error, FoPost.Error.t()}

Removes an asset from the library.

delete!(client, id)

Same as delete/2, but raises FoPost.Error.

list(client, opts \\ [])

@spec list(
  FoPost.Client.t(),
  keyword()
) :: {:ok, [FoPost.MediaAsset.t()]} | {:error, FoPost.Error.t()}

A workspace's media library. :workspace_id is required.

list!(client, opts \\ [])

Same as list/2, but raises FoPost.Error.

upload(client, opts)

@spec upload(
  FoPost.Client.t(),
  keyword()
) :: {:ok, [FoPost.MediaAsset.t()]} | {:error, FoPost.Error.t()}

Stores files in the media library.

Required: :files. Pass :workspace_id to save them to that workspace's library.

upload!(client, opts)

Same as upload/2, but raises FoPost.Error.