Download (#2)
simodels Build / Test Suite (push) Successful in 1m18s
simodels Build / build (push) Successful in 1m21s
simodels Build / Check (push) Successful in 1m25s
labyrinth release Tagging / release (push) Successful in 1m46s
simodels Build / Rustfmt (push) Successful in 1m54s
simodels Build / Clippy (push) Successful in 2m36s

Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
2026-08-10 17:41:33 -04:00
parent a3901c7a8e
commit 6ed1d00a32
5 changed files with 124 additions and 4 deletions
+28 -2
View File
@@ -37,8 +37,7 @@ pub async fn init_client(config: &config::Config) -> aws_sdk_s3::Client {
.force_path_style(true)
.build();
let client = aws_sdk_s3::Client::from_conf(s3_config);
client
aws_sdk_s3::Client::from_conf(s3_config)
}
#[derive(Debug)]
@@ -77,4 +76,31 @@ impl Labyrinth {
Err(err) => Err(Error::Info(err.to_string())),
}
}
pub async fn download(&self, file_key: &str) -> Result<Vec<u8>, Error> {
let client = init_client(&self.config).await;
match client
.get_object()
.bucket(self.config.bucket.clone())
.key(file_key)
.send()
.await
{
Ok(response) => {
let body = response.body;
// Get the body as ByteStream
match body.collect().await {
Ok(data) => {
let bytes = data.into_bytes();
let raw_data = bytes.to_vec();
Ok(raw_data)
}
Err(err) => Err(Error::Info(err.to_string())),
}
}
Err(err) => Err(Error::Info(err.to_string())),
}
}
}