# `Tesla.Multipart`
[🔗](https://github.com/elixir-tesla/tesla/blob/v1.17.0/lib/tesla/multipart.ex#L1)

Multipart functionality.

## Examples

```
mp =
  Multipart.new()
  |> Multipart.add_content_type_param("charset=utf-8")
  |> Multipart.add_field("field1", "foo")
  |> Multipart.add_field("field2", "bar",
    headers: [{"content-id", "1"}, {"content-type", "text/plain"}]
  )
  |> Multipart.add_file("test/tesla/multipart_test_file.sh")
  |> Multipart.add_file("test/tesla/multipart_test_file.sh", name: "foobar")
  |> Multipart.add_file_content("sample file content", "sample.txt")

response = client.post(url, mp)
```

# `part_stream`

```elixir
@type part_stream() :: Enum.t()
```

# `part_value`

```elixir
@type part_value() :: iodata() | part_stream() | function()
```

# `t`

```elixir
@type t() :: %Tesla.Multipart{
  boundary: String.t(),
  content_type_params: [String.t()],
  parts: [Tesla.Multipart.Part.t()]
}
```

# `add_content_type_param`

```elixir
@spec add_content_type_param(t(), String.t()) :: t()
```

Add a parameter to the multipart content-type.

# `add_field`

```elixir
@spec add_field(t(), String.t(), part_value(), Keyword.t()) :: t() | no_return()
```

Add a field part.

# `add_file`

```elixir
@spec add_file(t(), String.t(), Keyword.t()) :: t()
```

Add a file part. The file will be streamed.

## Options

- `:name` - name of form param
- `:filename` - filename (defaults to path basename)
- `:headers` - additional headers
- `:detect_content_type` - auto-detect file content-type (defaults to false)

# `add_file_content`

```elixir
@spec add_file_content(t(), part_value(), String.t(), Keyword.t()) :: t()
```

Add a file part with value.

Same as `add_file/3` but the file content is read from `data` input argument.

## Options

- `:name` - name of form param
- `:headers` - additional headers

# `new`

```elixir
@spec new() :: t()
```

Create a new Multipart struct to be used for a request body.

---

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