dc09bin/src/api.rs
2024-03-09 20:13:36 +04:00

16 lines
556 B
Rust

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())
}