# `Jibu.Files`
[🔗](https://github.com/oliverandrich/jibu/blob/v0.2.1/lib/jibu/files.ex#L1)

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](files.md).

# `delete`

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

Deletes a file.

# `download`

```elixir
@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`

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

Retrieves a file's metadata.

# `list`

```elixir
@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`

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

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

# `upload`

```elixir
@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`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
