Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/feliwir/multipart-rs
https://github.com/feliwir/multipart-rs
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/feliwir/multipart-rs
- Owner: feliwir
- Created: 2024-02-29T15:57:47.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-07-25T12:23:57.000Z (4 months ago)
- Last Synced: 2024-11-01T09:44:20.244Z (12 days ago)
- Language: Rust
- Size: 24.4 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Multipart-RS
A simple, zero-allocation, streaming, async multipart reader & writer for Rust
## Reading multipart
```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,
}
}
```