MCPcopy Create free account
hub / github.com/bytecodealliance/wstd / list

Function list

aws-example/src/bin/s3.rs:105–131  ·  view source on GitHub ↗
(bucket: &str, client: &Client)

Source from the content-addressed store, hash-verified

103}
104
105async fn list(bucket: &str, client: &Client) -> Result<String> {
106 let mut listing = client
107 .list_objects_v2()
108 .bucket(bucket.to_owned())
109 .into_paginator()
110 .send();
111
112 let mut output = String::new();
113 output += "key\tetag\tlast_modified\tstorage_class\n";
114 while let Some(res) = listing.next().await {
115 let object = res?;
116 for item in object.contents() {
117 output += &format!(
118 "{}\t{}\t{}\t{}\n",
119 item.key().unwrap_or_default(),
120 item.e_tag().unwrap_or_default(),
121 item.last_modified()
122 .map(|lm| format!("{lm}"))
123 .unwrap_or_default(),
124 item.storage_class()
125 .map(|sc| format!("{sc}"))
126 .unwrap_or_default(),
127 );
128 }
129 }
130 Ok(output)
131}
132
133async fn get(bucket: &str, client: &Client, key: &str) -> Result<Vec<u8>> {
134 let object = client

Callers 1

mainFunction · 0.85

Calls 3

contentsMethod · 0.80
sendMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected