docs
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use actix_web::error::ErrorInternalServerError;
|
||||
use aws_sdk_s3::{error::SdkError, primitives::ByteStream, Client as S3Client};
|
||||
use infer::get;
|
||||
use mime_guess::mime;
|
||||
use std::str::FromStr;
|
||||
use infer::get;
|
||||
|
||||
/// Загружает файл в S3 хранилище.
|
||||
pub async fn upload_to_s3(
|
||||
@@ -32,7 +32,13 @@ pub async fn check_file_exists(
|
||||
bucket: &str,
|
||||
filepath: &str,
|
||||
) -> Result<bool, actix_web::Error> {
|
||||
match s3_client.head_object().bucket(bucket).key(filepath).send().await {
|
||||
match s3_client
|
||||
.head_object()
|
||||
.bucket(bucket)
|
||||
.key(filepath)
|
||||
.send()
|
||||
.await
|
||||
{
|
||||
Ok(_) => Ok(true), // Файл найден
|
||||
Err(SdkError::ServiceError(service_error)) if service_error.err().is_not_found() => {
|
||||
Ok(false) // Файл не найден
|
||||
@@ -117,6 +123,6 @@ pub fn get_extension_from_mime(mime_type: &str) -> Option<&str> {
|
||||
"image/webp" => Some("webp"),
|
||||
"image/heic" => Some("heic"),
|
||||
"image/tiff" => Some("tiff"),
|
||||
_ => None
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user