# `Multipart.Part`
[🔗](https://github.com/breakroom/multipart/blob/v0.6.1/lib/multipart/part.ex#L1)

Represents an individual part of a `Multipart` message.

# `body`

```elixir
@type body() :: binary() | Enum.t()
```

# `headers`

```elixir
@type headers() :: [{binary(), binary()}]
```

# `name`

```elixir
@type name() :: String.t() | atom()
```

# `t`

```elixir
@type t() :: %Multipart.Part{
  body: body(),
  content_length: pos_integer() | nil,
  headers: []
}
```

# `binary_body`

```elixir
@spec binary_body(binary(), headers()) :: t()
```

Builds a `Part` with a binary body.

Set the `content_length` of the `Part` to the length of the binary.

# `file_body`

```elixir
@spec file_body(String.t(), headers()) :: t()
```

Builds a `Part` with a streaming file body.

Set the `content_length` of the `Part` to the size of the file on disk, as
inspected with `File.stat`.

# `file_content_field`

Builds a form-data `Part` with an in-memory file body.

Takes the following `Keyword` options in `opts`:

* `filename`: controls the inclusion of the `filename="foo"` directive in the
  `content-disposition` header. Defaults to `true`, which uses the filename
  from the path on disk. Pass in a `String` to override this, or set to
  `false` to disable this directive.

* `content_type`: controls the inclusion of the `content-type` header.
  Defaults to `true` which will use `MIME.from_path/1` to detect the mime
  type of the file. Pass in a `String` to override this, or set to `false`
  to disable this header.

# `file_field`

```elixir
@spec file_field(String.t(), name(), headers(), Keyword.t()) :: t()
```

Builds a form-data `Part` with a streaming file body.

Takes the following `Keyword` options in `opts`:

* `filename`: controls the inclusion of the `filename="foo"` directive in the
  `content-disposition` header. Defaults to `true`, which uses the filename
  from the path on disk. Pass in a `String` to override this, or set to
  `false` to disable this directive.

* `content_type`: controls the inclusion of the `content-type` header.
  Defaults to `true` which will use `MIME.from_path/1` to detect the mime
  type of the file. Pass in a `String` to override this, or set to `false`
  to disable this header.

# `stream_body`

```elixir
@spec stream_body(Enum.t(), headers()) :: t()
```

Builds a `Part` with a `Stream` body.

Because the length of the `Stream` cannot be known up front it doesn't
define the `content_length`. This will cause `Multipart.content_length/1`
to error unless you set the `content_length` manually in the struct.

# `stream_field`

```elixir
@spec stream_field(Enum.t(), name(), headers()) :: t()
```

Builds a form-data `Part` with a streaming body.

# `text_field`

```elixir
@spec text_field(binary(), name(), headers()) :: t()
```

Builds a form-data `Part` with a text body.

---

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