Jibu.Files (Jibu v0.2.1)

Copy Markdown View Source

The Files API: upload a file once and reference it by id. Jibu.Content builds the reference blocks. Results are the API's JSON with string keys. See the files guide.

Summary

Functions

Deletes a file.

Downloads a file's content as a binary. The API allows this only for files it created.

Retrieves a file's metadata.

Returns one page. query takes the API's parameters, such as :limit and :after_id.

Streams all files across pages, forward only. Raises Jibu.Error when a page fails.

Uploads a file from disk. The content type comes from the file extension.

Uploads a binary under the given filename and content type.

Functions

delete(client, id)

@spec delete(Req.Request.t(), String.t()) :: {:ok, map()} | {:error, Jibu.Error.t()}

Deletes a file.

download(client, id)

@spec download(Req.Request.t(), String.t()) ::
  {:ok, binary()} | {:error, Jibu.Error.t()}

Downloads a file's content as a binary. The API allows this only for files it created.

get(client, id)

@spec get(Req.Request.t(), String.t()) :: {:ok, map()} | {:error, Jibu.Error.t()}

Retrieves a file's metadata.

list(client, query \\ [])

@spec list(Req.Request.t(), keyword()) :: {:ok, map()} | {:error, Jibu.Error.t()}

Returns one page. query takes the API's parameters, such as :limit and :after_id.

stream(client, query \\ [])

@spec stream(Req.Request.t(), keyword()) :: Enumerable.t()

Streams all files across pages, forward only. Raises Jibu.Error when a page fails.

upload(client, path)

@spec upload(Req.Request.t(), Path.t()) :: {:ok, map()} | {:error, Jibu.Error.t()}

Uploads a file from disk. The content type comes from the file extension.

A missing or unreadable file raises File.Error, like Jibu.Content.image/2.

upload_data(client, data, filename, content_type)

@spec upload_data(Req.Request.t(), iodata() | Enumerable.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Jibu.Error.t()}

Uploads a binary under the given filename and content type.