Crates.io | multipart-rs |
lib.rs | multipart-rs |
version | 0.1.11 |
source | src |
created_at | 2024-03-01 13:54:27.051979 |
updated_at | 2024-07-25 12:24:03.000818 |
description | A simple, zero-allocation, streaming, async multipart reader & writer for Rust |
homepage | |
repository | https://www.github.com/feliwir/multipart-rs |
max_upload_size | |
id | 1158930 |
size | 19,038 |
A simple, zero-allocation, streaming, async multipart reader & writer for Rust
let headermap = vec![(
"Content-Type".to_string(),
"multipart/form-data; boundary=--974767299852498929531610575".to_string(),
)];
// Lines must end with CRLF
let data = b"--974767299852498929531610575\r
Content-Disposition: form-data; name=\"afile\"; filename=\"a.txt\"\r
\r
Content of a.txt.\r
--974767299852498929531610575\r
Content-Disposition: form-data; name=\"bfile\"; filename=\"b.txt\"\r
Content-Type: text/plain\r
\r
Content of b.txt.\r
--974767299852498929531610575--\r\n";
let reader = MultipartReader::from_data_with_headers(data, &headermap);
loop {
match reader.next().await {
Some(Ok(item)) => println!(item),
Some(Err(e)) => panic!("Error: {:?}", e),
None => break,
}
}