Crates.io | multiparty |
lib.rs | multiparty |
version | 0.1.0 |
source | src |
created_at | 2021-06-27 19:14:41.12236 |
updated_at | 2021-06-27 19:14:41.12236 |
description | Simple zero copy streaming multipart decoder implementation |
homepage | |
repository | https://github.com/paolobarbolini/multiparty |
max_upload_size | |
id | 415503 |
size | 75,307 |
Simple zero copy* streaming multipart decoder implementation.
Also exposes the underlying Sans IO decoder, for use outside of
the futures
0.3 ecosystem.
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");
}
Licensed under either of
at your option.
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.