1 unstable release

0.1.0 Jun 27, 2021

#693 in HTTP server

Download history 562/week @ 2024-03-28 506/week @ 2024-04-04 688/week @ 2024-04-11 487/week @ 2024-04-18 335/week @ 2024-04-25 366/week @ 2024-05-02 298/week @ 2024-05-09 336/week @ 2024-05-16 341/week @ 2024-05-23 474/week @ 2024-05-30 286/week @ 2024-06-06 384/week @ 2024-06-13 431/week @ 2024-06-20 448/week @ 2024-06-27 307/week @ 2024-07-04 224/week @ 2024-07-11

1,471 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

~130–295KB