heic-sys
Some checks failed
deploy / deploy (push) Failing after 6s

This commit is contained in:
2024-11-13 11:14:53 +03:00
parent fb1541f8e3
commit bc14d86018
9 changed files with 262 additions and 237 deletions

View File

@@ -2,6 +2,7 @@ use actix_web::error::ErrorInternalServerError;
use aws_sdk_s3::{error::SdkError, primitives::ByteStream, Client as S3Client};
use mime_guess::mime;
use std::str::FromStr;
use infer::get;
/// Загружает файл в S3 хранилище.
pub async fn upload_to_s3(
@@ -101,4 +102,21 @@ pub async fn get_s3_filelist(client: &S3Client, bucket: &str) -> Vec<[std::strin
}
}
filenames
}
pub fn detect_mime_type(bytes: &[u8]) -> Option<String> {
let kind = get(bytes)?;
Some(kind.mime_type().to_string())
}
pub fn get_extension_from_mime(mime_type: &str) -> Option<&str> {
match mime_type {
"image/jpeg" => Some("jpg"),
"image/png" => Some("png"),
"image/gif" => Some("gif"),
"image/webp" => Some("webp"),
"image/heic" => Some("heic"),
"image/tiff" => Some("tiff"),
_ => None
}
}