From 6d8ec28dbb8628d1ec96d3791203d42be8d32626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Henrique?= Date: Thu, 28 Sep 2023 22:53:09 -0300 Subject: [PATCH] save image --- ActixAPI/src/main.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ActixAPI/src/main.rs b/ActixAPI/src/main.rs index 6abe78d..878169d 100644 --- a/ActixAPI/src/main.rs +++ b/ActixAPI/src/main.rs @@ -29,6 +29,17 @@ async fn load_big_image() -> Result { Ok(NamedFile::open(real_path)?) } +#[post("/image/save-big-image")] +async fn save_big_image(image_data: web::Bytes) -> Result { + // Write bytes to file + std::fs::write("image.png", &image_data).unwrap(); + + // Return the blurred image bytes + Ok(HttpResponse::Ok() + .content_type("application/json") + .body("{\"status\": 200}")) +} + #[post("/image/blur")] async fn blur_image(image_data: web::Bytes, req: HttpRequest) -> Result { // Load the image from the incoming bytes @@ -61,7 +72,9 @@ async fn main() -> std::io::Result<()> { .service(hello) .service(load_small_image) .service(load_big_image) + .service(save_big_image) .service(blur_image) + .app_data(web::PayloadConfig::new(1024 * 1024 * 1024)) }) .bind(("0.0.0.0", 5000))? .run()