dc09bin/src/api.rs

17 lines
556 B
Rust
Raw Normal View History

2024-03-09 19:13:36 +03:00
use futures::{StreamExt, TryStreamExt};
use ntex::web::{self, Error, HttpResponse};
use ntex_multipart::Multipart;
#[web::post("/api/upload")]
async fn upload(mut payload: Multipart) -> Result<HttpResponse, Error> {
while let Ok(Some(mut field)) = payload.try_next().await {
println!("CT: {:?}", field.content_type());
println!("H: {:?}", field.headers());
while let Some(chunk) = field.next().await {
println!("-- CHUNK: \n{:?}", std::str::from_utf8(&chunk?));
}
}
Ok(HttpResponse::Ok().into())
}