(&self, key: &str, file_path: Option<&str>)
| 53 | } |
| 54 | |
| 55 | async fn get_object(&self, key: &str, file_path: Option<&str>) -> Result<Vec<u8>, String> { |
| 56 | let key_with_prefix; |
| 57 | if let Some(path) = file_path { |
| 58 | key_with_prefix = format! {"{path}/{key}"}; |
| 59 | } else { |
| 60 | key_with_prefix = key.to_string(); |
| 61 | } |
| 62 | |
| 63 | let mut data = self |
| 64 | .client |
| 65 | .get_object() |
| 66 | .bucket(&self.bucket) |
| 67 | .key(key_with_prefix) |
| 68 | .send() |
| 69 | .await |
| 70 | .map_err(err_to_string)?; |
| 71 | |
| 72 | let mut buffer: Vec<u8> = vec![]; |
| 73 | while let Some(bytes) = data.body.try_next().await.map_err(err_to_string)? { |
| 74 | buffer.append(&mut bytes.to_vec()); |
| 75 | } |
| 76 | |
| 77 | Ok(buffer) |
| 78 | } |
| 79 | |
| 80 | async fn upload_object( |
| 81 | &self, |
no test coverage detected