chore: move image stuff to axum-image
This commit is contained in:
parent
dbed2b2457
commit
e8cc541f45
15 changed files with 48 additions and 244 deletions
|
@ -3,13 +3,11 @@ use crate::cookie::CookieJar;
|
|||
use pathbufd::{PathBufD, pathd};
|
||||
use std::fs::exists;
|
||||
use tetratto_core::model::{ApiReturn, Error, permissions::FinePermission, oauth};
|
||||
|
||||
use crate::{
|
||||
State,
|
||||
image::{Image, save_buffer},
|
||||
get_user_from_token,
|
||||
State, get_user_from_token,
|
||||
routes::api::v1::auth::images::{MAXIMUM_FILE_SIZE, read_image},
|
||||
};
|
||||
use axum_image::{encode::save_image_buffer, extract::Image};
|
||||
|
||||
/// Get a community's avatar image
|
||||
/// `/api/v1/communities/{id}/avatar`
|
||||
|
@ -146,7 +144,7 @@ pub async fn upload_avatar_request(
|
|||
bytes.push(byte);
|
||||
}
|
||||
|
||||
match save_buffer(&path, bytes, image::ImageFormat::Avif) {
|
||||
match save_image_buffer(&path, bytes, axum_image::ImageFormat::Avif) {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Avatar uploaded. It might take a bit to update".to_string(),
|
||||
|
@ -201,7 +199,7 @@ pub async fn upload_banner_request(
|
|||
bytes.push(byte);
|
||||
}
|
||||
|
||||
match save_buffer(&path, bytes, image::ImageFormat::Avif) {
|
||||
match save_image_buffer(&path, bytes, axum_image::ImageFormat::Avif) {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Banner uploaded. It might take a bit to update".to_string(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue