Skip to main content

Module multipart

Module multipart 

Source
Available on crate features client and multipart only.
Expand description

Client-side multipart/form-data builder.

This module provides Form and Part for building a multipart/form-data body for client requests, which is the counterpart of the server-side Multipart extractor.

Form collects a series of Parts and can be sent with RequestBuilder::multipart. Each Part can be built from in-memory bytes/text, an arbitrary AsyncRead reader, or a file path (which is streamed lazily).

§Example

use volo_http::client::multipart::{Form, Part};

let form = Form::new()
    .text("key", "value")
    .part(
        "file",
        Part::text("hello, world")
            .file_name("hello.txt")
            .mime_str("text/plain")?,
    );

let resp = client.post("http://127.0.0.1:8080/upload").multipart(form).send().await?;

Structs§

Form
A multipart/form-data request body.
Part
A single field of a Form.