parent
5b7d84de03
commit
bdda6b6341
|
@ -112,7 +112,14 @@ 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![
|
||||||
|
stored_path.clone(),
|
||||||
|
format!("production/{}", stored_path)
|
||||||
|
];
|
||||||
|
|
||||||
|
for path in aws_paths {
|
||||||
|
warn!("Trying AWS path: {}", path);
|
||||||
|
match load_file_from_s3(&state.aws_client, &state.bucket, &path).await {
|
||||||
Ok(filedata) => {
|
Ok(filedata) => {
|
||||||
warn!("Successfully loaded file from AWS, size: {} bytes", filedata.len());
|
warn!("Successfully loaded file from AWS, size: {} bytes", filedata.len());
|
||||||
warn!("Attempting to upload to Storj with key: {}", filekey);
|
warn!("Attempting to upload to Storj with key: {}", filekey);
|
||||||
|
@ -129,13 +136,17 @@ pub async fn proxy_handler(
|
||||||
warn!("Successfully uploaded to Storj: {}", filekey);
|
warn!("Successfully uploaded to Storj: {}", filekey);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(HttpResponse::Ok().content_type(content_type).body(filedata))
|
return Ok(HttpResponse::Ok().content_type(content_type).body(filedata));
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Failed to load from AWS: {} - Full error: {:?}", stored_path, err);
|
warn!("Failed to load from AWS path {}: {:?}", path, err);
|
||||||
Err(ErrorInternalServerError(err))
|
continue;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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