Compare commits

..
Author SHA1 Message Date
phoenix 2b6127f6a6 Code formatting
simodels Build / Rustfmt (pull_request) Successful in 1m54s
labyrinth release Tagging / release (pull_request) Successful in 1m54s
simodels Build / Clippy (pull_request) Successful in 2m30s
simodels Build / Test Suite (pull_request) Successful in 2m52s
simodels Build / build (pull_request) Successful in 2m53s
simodels Build / Check (pull_request) Successful in 2m56s
2026-08-10 17:16:18 -04:00
phoenix 8464401337 Adding code to download from the bucket 2026-08-10 17:14:48 -04:00
+28 -2
View File
@@ -37,8 +37,7 @@ pub async fn init_client(config: &config::Config) -> aws_sdk_s3::Client {
.force_path_style(true) .force_path_style(true)
.build(); .build();
let client = aws_sdk_s3::Client::from_conf(s3_config); aws_sdk_s3::Client::from_conf(s3_config)
client
} }
#[derive(Debug)] #[derive(Debug)]
@@ -77,4 +76,31 @@ impl Labyrinth {
Err(err) => Err(Error::Info(err.to_string())), 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())),
}
}
} }