MCPcopy Create free account
hub / github.com/cosdata/cosdata / download_file

Method download_file

org/src/s3_client.rs:89–108  ·  view source on GitHub ↗
(&self, key: &str, output_path: &str)

Source from the content-addressed store, hash-verified

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()

Callers 1

mainFunction · 0.80

Calls 2

get_objectMethod · 0.80
keyMethod · 0.45

Tested by

no test coverage detected