0.0.6-onecachekey
This commit is contained in:
@@ -5,14 +5,14 @@ use std::str::FromStr;
|
||||
|
||||
/// Загружает файл в S3 хранилище.
|
||||
pub async fn upload_to_s3(
|
||||
s3_client: &S3Client,
|
||||
storj_client: &S3Client,
|
||||
bucket: &str,
|
||||
key: &str,
|
||||
body: Vec<u8>,
|
||||
content_type: &str,
|
||||
) -> Result<String, actix_web::Error> {
|
||||
let body_stream = ByteStream::from(body); // Преобразуем тело файла в поток байтов
|
||||
s3_client
|
||||
storj_client
|
||||
.put_object()
|
||||
.bucket(bucket)
|
||||
.key(key)
|
||||
@@ -27,11 +27,11 @@ pub async fn upload_to_s3(
|
||||
|
||||
/// Проверяет, существует ли файл в S3.
|
||||
pub async fn check_file_exists(
|
||||
s3_client: &S3Client,
|
||||
storj_client: &S3Client,
|
||||
bucket: &str,
|
||||
file_key: &str,
|
||||
) -> Result<bool, actix_web::Error> {
|
||||
match s3_client.head_object().bucket(bucket).key(file_key).send().await {
|
||||
match storj_client.head_object().bucket(bucket).key(file_key).send().await {
|
||||
Ok(_) => Ok(true), // Файл найден
|
||||
Err(SdkError::ServiceError(service_error)) if service_error.err().is_not_found() => {
|
||||
Ok(false) // Файл не найден
|
||||
@@ -42,11 +42,11 @@ pub async fn check_file_exists(
|
||||
|
||||
/// Загружает файл из S3.
|
||||
pub async fn load_file_from_s3(
|
||||
s3_client: &S3Client,
|
||||
storj_client: &S3Client,
|
||||
bucket: &str,
|
||||
key: &str,
|
||||
) -> Result<Vec<u8>, actix_web::Error> {
|
||||
let get_object_output = s3_client
|
||||
let get_object_output = storj_client
|
||||
.get_object()
|
||||
.bucket(bucket)
|
||||
.key(key)
|
||||
|
||||
Reference in New Issue
Block a user