#form-data #zero-copy #http #async #sans-io #multipart

multiparty

Simple zero copy streaming multipart decoder implementation

1 unstable release

0.1.0 Jun 27, 2021

#712 in HTTP server

Download history 365/week @ 2024-07-21 339/week @ 2024-07-28 269/week @ 2024-08-04 371/week @ 2024-08-11 366/week @ 2024-08-18 317/week @ 2024-08-25 321/week @ 2024-09-01 314/week @ 2024-09-08 297/week @ 2024-09-15 373/week @ 2024-09-22 276/week @ 2024-09-29 151/week @ 2024-10-06 403/week @ 2024-10-13 664/week @ 2024-10-20 613/week @ 2024-10-27 582/week @ 2024-11-03

2,278 downloads per month
Used in warp-fix-171

MIT/Apache

42KB
884 lines

multiparty

crates.io Documentation dependency status Rustc Version 1.45.2+ CI codecov

Simple zero copy* streaming multipart decoder implementation.

Also exposes the underlying Sans IO decoder, for use outside of the futures 0.3 ecosystem.

Examples

multiparty = { version = "0.1", features = ["server", "futures03"] }
use multiparty::server::owned_futures03::FormData;
use futures_util::stream::TryStreamExt;

let boundary = todo!("A multipart/form-data boundary");
let stream = todo!("A Stream<Item = std::io::Result<Bytes>> + Unpin");
let mut multipart = FormData::new(stream, boundary);

while let Some(mut part) = multipart.try_next().await? {
    let headers = part.raw_headers().parse()?;
    println!("name: {:?}", headers.name);
    println!("filename: {:?}", headers.filename);
    println!("content_type: {:?}", headers.content_type);

    while let Some(bytes) = part.try_next().await? {
        println!("Read {} bytes from the current part", bytes.len());
    }

    println!("Reached the end of this part");
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.


* Except for streams yielding Bytes smaller than half the boundary length.

Dependencies

~135–290KB