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

Method get_object

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

Source from the content-addressed store, hash-verified

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,

Callers 2

fetch_objectMethod · 0.45

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected