MCPcopy Create free account
hub / github.com/BitVM/BitVM / list_objects

Method list_objects

bridge/src/client/data_store/aws_s3.rs:105–136  ·  view source on GitHub ↗
(&self, file_path: Option<&str>)

Source from the content-addressed store, hash-verified

103#[async_trait]
104impl DataStoreDriver for AwsS3 {
105 async fn list_objects(&self, file_path: Option<&str>) -> Result<Vec<String>, String> {
106 let mut prefix = String::from("");
107 if let Some(path) = file_path {
108 prefix = format! {"{path}/"};
109 }
110
111 let mut response = self
112 .client
113 .list_objects_v2()
114 .prefix(prefix)
115 .bucket(&self.bucket)
116 .max_keys(50) // Paginate 50 results at a time
117 .into_paginator()
118 .send();
119
120 let mut keys: Vec<String> = vec![];
121 while let Some(result) = response.next().await {
122 match result {
123 Ok(output) => {
124 for object in output.contents() {
125 keys.push(object.key().unwrap_or("Unknown").to_string());
126 }
127 }
128 Err(err) => {
129 eprintln!("{err:?}");
130 return Err("Unable to list objects".to_string());
131 }
132 }
133 }
134
135 Ok(keys)
136 }
137
138 async fn fetch_object(
139 &self,

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected