0.0.6-onecachekey
This commit is contained in:
@@ -26,7 +26,7 @@ pub async fn upload_handler(
|
||||
|
||||
// Получаем текущую квоту пользователя
|
||||
let this_week_amount: u64 = state.get_or_create_quota(&user_id).await.unwrap_or(0);
|
||||
|
||||
let mut body = "ok".to_string();
|
||||
while let Ok(Some(field)) = payload.try_next().await {
|
||||
let mut field = field;
|
||||
|
||||
@@ -57,22 +57,21 @@ pub async fn upload_handler(
|
||||
let _ = state.increment_uploaded_bytes(&user_id, file_size).await?;
|
||||
|
||||
// Определяем правильное расширение и ключ для S3
|
||||
let file_key = generate_key_with_extension(name, content_type.to_owned());
|
||||
body = generate_key_with_extension(name, content_type.to_owned());
|
||||
|
||||
// Загружаем файл в S3
|
||||
upload_to_s3(
|
||||
&state.s3_client,
|
||||
&state.s3_bucket,
|
||||
&file_key,
|
||||
&state.storj_client,
|
||||
&state.storj_bucket,
|
||||
&body,
|
||||
file_bytes,
|
||||
&content_type,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Сохраняем информацию о загруженном файле для пользователя
|
||||
user_added_file(&mut state.redis.clone(), &user_id, &file_key).await?;
|
||||
user_added_file(&mut state.redis.clone(), &user_id, &body).await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(HttpResponse::Ok().json("File uploaded successfully"))
|
||||
Ok(HttpResponse::Ok().body(body))
|
||||
}
|
||||
|
Reference in New Issue
Block a user