From ec720f2e6e3cef24f194d8887b8fa32c22b706bd Mon Sep 17 00:00:00 2001 From: Andrew Aquino Date: Fri, 4 Jun 2021 08:12:05 -0700 Subject: [PATCH] print error from aws download --- src/cache/s3.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/cache/s3.rs b/src/cache/s3.rs index 1d248fe..bb2773f 100644 --- a/src/cache/s3.rs +++ b/src/cache/s3.rs @@ -13,7 +13,10 @@ pub async fn download_from_s3( let f_name = { filename.clone() }; let path_str = f_name.split("/").last().unwrap_or(""); let object_key = format!("{}/{}", prefix, path_str).to_string(); - println!("Downloading {}/{}...", bucket, object_key); + let _bucket = bucket.clone(); + let _object_key = object_key.clone(); + + println!("Downloading {}/{}...", bucket.clone(), object_key); let request = GetObjectRequest { bucket, @@ -23,11 +26,19 @@ pub async fn download_from_s3( let stream = s3_client.get_object(request).await; - let stream = stream?.body.take().expect("no body"); + let mut output = match stream { + Ok(output) => output, + Err(error) => panic!(error.to_string()), + }; + + let stream = output.body.take().expect("No Content"); + let mut body = stream.into_async_read(); let mut file = tokio::fs::File::create(filename).await.unwrap(); tokio::io::copy(&mut body, &mut file).await.ok(); + println!("Downloaded {}/{}", _bucket, _object_key); + Ok(()) }