use crate::is3::s3_download_to_memory::s3_download_to_memory;
use std::fs;
pub async fn s3_download_to_file(
file_path: &str,
bucket: &str,
key: &str,
) -> Result<String, String> {
match s3_download_to_memory(bucket, key).await {
Ok(s3_contents) => {
if false {
info!(
"s3_download_to_file - saving - \
s3://{bucket}/{key} \
at {file_path}"
);
}
fs::write(file_path, s3_contents).unwrap();
if false {
info!(
"s3_download_to_file - saved - \
s3://{bucket}/{key} \
at {file_path}"
);
}
Ok(file_path.to_string())
}
Err(emsg) => Err(emsg),
}
}