return image response instead vector

This commit is contained in:
Timofey Gelazoniya 2023-04-03 04:38:25 +03:00
parent b7e83f921a
commit 573261911d
Signed by: zeldon
GPG Key ID: 047886915281DD2A

View File

@ -1,10 +1,19 @@
use axum::{extract::Multipart, Json};
use axum::{
body::Full,
extract::Multipart,
http::HeaderMap,
response::{IntoResponse, Response},
};
use crate::{
processors::liquid_rescale_processor::liquid_rescale_processor, utilities::app_error::AppError,
};
pub async fn liquid_rescale_route(multipart: Multipart) -> Result<Json<Vec<u8>>, AppError> {
pub async fn liquid_rescale_route(multipart: Multipart) -> Result<Response, AppError> {
let image_data = liquid_rescale_processor(multipart).await?;
Ok(Json(image_data))
let body = Full::from(image_data);
let mut headers = HeaderMap::new();
headers.insert("Content-Type", "image/jpeg".parse().unwrap());
Ok((headers, body).into_response())
}