| 108 | } |
| 109 | |
| 110 | fn list_objects(&self, prefix: &str) -> Result<Vec<String>, Box<dyn Error>> { |
| 111 | let rt = tokio::runtime::Builder::new_current_thread() |
| 112 | .enable_all() |
| 113 | .build()?; |
| 114 | |
| 115 | rt.block_on(async { |
| 116 | let result = self.client |
| 117 | .list_objects_v2() |
| 118 | .bucket(&self.bucket) |
| 119 | .prefix(prefix) |
| 120 | .send() |
| 121 | .await?; |
| 122 | |
| 123 | let mut keys = Vec::new(); |
| 124 | if let Some(objects) = result.contents { |
| 125 | for obj in objects { |
| 126 | if let Some(key) = obj.key { |
| 127 | keys.push(key); |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | Ok(keys) |
| 133 | }) |
| 134 | } |
| 135 | |
| 136 | fn delete_object(&self, key: &str) -> Result<(), Box<dyn Error>> { |
| 137 | let rt = tokio::runtime::Builder::new_current_thread() |