This commit is contained in:
parent
1b4e12c120
commit
5283a878ed
|
@ -104,14 +104,18 @@ pub async fn proxy_handler(
|
||||||
{
|
{
|
||||||
Ok(filedata) => {
|
Ok(filedata) => {
|
||||||
warn!("download stored_path from aws: {:?}", stored_path);
|
warn!("download stored_path from aws: {:?}", stored_path);
|
||||||
let _ = upload_to_s3(
|
if let Err(e) = upload_to_s3(
|
||||||
&state.storj_client,
|
&state.storj_client,
|
||||||
&state.bucket,
|
&state.bucket,
|
||||||
&filekey,
|
&filekey,
|
||||||
filedata.clone(),
|
filedata.clone(),
|
||||||
content_type,
|
content_type,
|
||||||
)
|
)
|
||||||
.await;
|
.await {
|
||||||
|
warn!("cannot upload to storj: {}", e);
|
||||||
|
} else {
|
||||||
|
warn!("file {} uploaded to storj", filekey);
|
||||||
|
}
|
||||||
thumbdata_save(filedata.clone(), &state, &filekey, content_type.to_string())
|
thumbdata_save(filedata.clone(), &state, &filekey, content_type.to_string())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use actix_multipart::Multipart;
|
use actix_multipart::Multipart;
|
||||||
use actix_web::{web, HttpRequest, HttpResponse, Result};
|
use actix_web::{web, HttpRequest, HttpResponse, Result};
|
||||||
|
use log::warn;
|
||||||
|
|
||||||
use crate::app_state::AppState;
|
use crate::app_state::AppState;
|
||||||
use crate::auth::{get_id_by_token, user_added_file};
|
use crate::auth::{get_id_by_token, user_added_file};
|
||||||
|
@ -60,14 +61,18 @@ pub async fn upload_handler(
|
||||||
body = generate_key_with_extension(name, content_type.to_owned());
|
body = generate_key_with_extension(name, content_type.to_owned());
|
||||||
|
|
||||||
// Загружаем файл в S3
|
// Загружаем файл в S3
|
||||||
upload_to_s3(
|
if let Err(e) = upload_to_s3(
|
||||||
&state.storj_client,
|
&state.storj_client,
|
||||||
&state.bucket,
|
&state.bucket,
|
||||||
&body,
|
&body,
|
||||||
file_bytes,
|
file_bytes,
|
||||||
&content_type,
|
&content_type,
|
||||||
)
|
)
|
||||||
.await?;
|
.await {
|
||||||
|
warn!("cannot upload to storj: {}", e);
|
||||||
|
} else {
|
||||||
|
warn!("file {} uploaded to storj", body);
|
||||||
|
}
|
||||||
|
|
||||||
// Сохраняем информацию о загруженном файле для пользователя
|
// Сохраняем информацию о загруженном файле для пользователя
|
||||||
user_added_file(&mut state.redis.clone(), &user_id, &body).await?;
|
user_added_file(&mut state.redis.clone(), &user_id, &body).await?;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user