# `Storehouse.Tus.State`
[🔗](https://github.com/hattoriai/storehouse/blob/v0.2.0/lib/storehouse/tus.ex#L87)

Where `Storehouse.Tus.Plug` keeps each upload between requests: its key,
size, offset, metadata and, on a store of multipart uploads, its parts
and the bytes not yet a part. `Storehouse.Tus.State.ETS` is the default,
one node's.

An upload is a map with an `:id` (`t:upload/0`). Every field of it must
be kept as it is: in a database, as an Erlang term (`:erlang.term_to_binary/1`,
in a `bytea` column) beside the id and `expires_at`.

# `upload`

```elixir
@type upload() :: %{
  :id =&gt; String.t(),
  :expires_at =&gt; DateTime.t(),
  optional(atom()) =&gt; term()
}
```

An upload in progress, as the plug keeps it.

# `delete`

```elixir
@callback delete(String.t()) :: :ok
```

Forgets the upload with `id`.

# `expired`

```elixir
@callback expired(now :: DateTime.t()) :: [upload()]
```

The uploads whose `:expires_at` is before `now`.

# `get`

```elixir
@callback get(String.t()) :: upload() | nil
```

The upload with `id`, or `nil`.

# `owned`
*optional* 

```elixir
@callback owned(owner :: String.t()) :: [upload()]
```

The uploads in progress of `owner` (an upload's `:owner`): with it, the
plug limits how many one owner has at once (`:max_uploads`), and counts
their sizes against its `:room`.

# `put`

```elixir
@callback put(upload()) :: :ok
```

Keeps `upload`, in place of the one with its id.

---

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