Skip to content

Commit

Permalink
feat(http): add multipart for server
Browse files Browse the repository at this point in the history
  • Loading branch information
StellarisW committed Oct 25, 2024
1 parent 6bcb033 commit 94b27ef
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions volo-http/src/server/utils/multipart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//!
//! async fn upload(mut multipart: Multipart) -> Result<StatusCode, MultipartRejectionError> {
//! while let Some(field) = multipart.next_field().await? {
//! let name = field.name().unwrap();
//! let name = field.name().unwrap().to_string();
//! let value = field.bytes().await?;
//!
//! println!("The field {} has {} bytes", name, value.len());
Expand Down Expand Up @@ -109,10 +109,10 @@ impl Multipart {
/// # use volo_http::server::utils::multipart::Multipart;
/// # let mut multipart: Multipart;
/// // Extract each field from multipart by using while loop
/// # async {
/// while let Some(field) = multipart.next_field().await? {
/// # async fn upload(mut multipart: Multipart) {
/// while let Some(field) = multipart.next_field().await.unwrap() {
/// let name = field.name().unwrap().to_string(); // Get field name
/// let data = field.bytes().await?; // Get field data
/// let data = field.bytes().await.unwrap(); // Get field data
/// }
/// # }
/// ```
Expand Down Expand Up @@ -210,7 +210,6 @@ mod multipart_tests {
};

use motore::Service;
use rand::Rng;
use reqwest::multipart::Form;
use volo::net::Address;

Expand All @@ -219,13 +218,11 @@ mod multipart_tests {
request::ServerRequest,
response::ServerResponse,
server::{
layer::BodyLimitLayer,
route::post,
test_helpers,
utils::multipart::{Multipart, MultipartRejectionError},
IntoResponse,
},
Router, Server,
Server,
};

fn _test_compile() {
Expand Down

0 comments on commit 94b27ef

Please sign in to comment.