mirror of https://github.com/ivanch/tcc.git
save image
This commit is contained in:
parent
4535ed5cf6
commit
6d8ec28dbb
|
@ -29,6 +29,17 @@ async fn load_big_image() -> Result<NamedFile> {
|
||||||
Ok(NamedFile::open(real_path)?)
|
Ok(NamedFile::open(real_path)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[post("/image/save-big-image")]
|
||||||
|
async fn save_big_image(image_data: web::Bytes) -> Result<HttpResponse> {
|
||||||
|
// 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")]
|
#[post("/image/blur")]
|
||||||
async fn blur_image(image_data: web::Bytes, req: HttpRequest) -> Result<HttpResponse> {
|
async fn blur_image(image_data: web::Bytes, req: HttpRequest) -> Result<HttpResponse> {
|
||||||
// Load the image from the incoming bytes
|
// Load the image from the incoming bytes
|
||||||
|
@ -61,7 +72,9 @@ async fn main() -> std::io::Result<()> {
|
||||||
.service(hello)
|
.service(hello)
|
||||||
.service(load_small_image)
|
.service(load_small_image)
|
||||||
.service(load_big_image)
|
.service(load_big_image)
|
||||||
|
.service(save_big_image)
|
||||||
.service(blur_image)
|
.service(blur_image)
|
||||||
|
.app_data(web::PayloadConfig::new(1024 * 1024 * 1024))
|
||||||
})
|
})
|
||||||
.bind(("0.0.0.0", 5000))?
|
.bind(("0.0.0.0", 5000))?
|
||||||
.run()
|
.run()
|
||||||
|
|
Loading…
Reference in New Issue