(&self, key: &str, output_path: &str)
| 87 | } |
| 88 | |
| 89 | fn download_file(&self, key: &str, output_path: &str) -> Result<(), Box<dyn Error>> { |
| 90 | let rt = tokio::runtime::Builder::new_current_thread() |
| 91 | .enable_all() |
| 92 | .build()?; |
| 93 | |
| 94 | rt.block_on(async { |
| 95 | let result = self.client |
| 96 | .get_object() |
| 97 | .bucket(&self.bucket) |
| 98 | .key(key) |
| 99 | .send() |
| 100 | .await?; |
| 101 | |
| 102 | let bytes = result.body.collect().await?.into_bytes(); |
| 103 | std::fs::write(output_path, bytes)?; |
| 104 | |
| 105 | println!("Downloaded s3://{}/{} to {}", self.bucket, key, output_path); |
| 106 | Ok(()) |
| 107 | }) |
| 108 | } |
| 109 | |
| 110 | fn list_objects(&self, prefix: &str) -> Result<Vec<String>, Box<dyn Error>> { |
| 111 | let rt = tokio::runtime::Builder::new_current_thread() |
no test coverage detected