parent
5b7d84de03
commit
bdda6b6341
|
@ -112,30 +112,41 @@ pub async fn proxy_handler(
|
||||||
} else {
|
} else {
|
||||||
warn!("Attempting to load from AWS - bucket: {}, path: {}", state.bucket, stored_path);
|
warn!("Attempting to load from AWS - bucket: {}, path: {}", state.bucket, stored_path);
|
||||||
|
|
||||||
return match load_file_from_s3(&state.aws_client, &state.bucket, &stored_path).await {
|
let aws_paths = vec![
|
||||||
Ok(filedata) => {
|
stored_path.clone(),
|
||||||
warn!("Successfully loaded file from AWS, size: {} bytes", filedata.len());
|
format!("production/{}", stored_path)
|
||||||
warn!("Attempting to upload to Storj with key: {}", filekey);
|
];
|
||||||
|
|
||||||
if let Err(e) = upload_to_s3(
|
for path in aws_paths {
|
||||||
&state.storj_client,
|
warn!("Trying AWS path: {}", path);
|
||||||
&state.bucket,
|
match load_file_from_s3(&state.aws_client, &state.bucket, &path).await {
|
||||||
&filekey,
|
Ok(filedata) => {
|
||||||
filedata.clone(),
|
warn!("Successfully loaded file from AWS, size: {} bytes", filedata.len());
|
||||||
content_type,
|
warn!("Attempting to upload to Storj with key: {}", filekey);
|
||||||
).await {
|
|
||||||
error!("Failed to upload to Storj: {} - Error: {}", filekey, e);
|
if let Err(e) = upload_to_s3(
|
||||||
} else {
|
&state.storj_client,
|
||||||
warn!("Successfully uploaded to Storj: {}", filekey);
|
&state.bucket,
|
||||||
|
&filekey,
|
||||||
|
filedata.clone(),
|
||||||
|
content_type,
|
||||||
|
).await {
|
||||||
|
error!("Failed to upload to Storj: {} - Error: {}", filekey, e);
|
||||||
|
} else {
|
||||||
|
warn!("Successfully uploaded to Storj: {}", filekey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(HttpResponse::Ok().content_type(content_type).body(filedata));
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
warn!("Failed to load from AWS path {}: {:?}", path, err);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(HttpResponse::Ok().content_type(content_type).body(filedata))
|
|
||||||
}
|
}
|
||||||
Err(err) => {
|
}
|
||||||
error!("Failed to load from AWS: {} - Full error: {:?}", stored_path, err);
|
|
||||||
Err(ErrorInternalServerError(err))
|
error!("Failed to load from any AWS path for: {}", stored_path);
|
||||||
}
|
Err(ErrorInternalServerError("Failed to load file from AWS"))
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user