aboutsummaryrefslogtreecommitdiff
path: root/src/storage/garage.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2023-12-21 21:54:36 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2023-12-21 21:54:36 +0100
commit012c6ad6724b6a6e155ee717e6d558e1fe199e43 (patch)
tree986377de04024911c1c460e41828dde546d5a6a6 /src/storage/garage.rs
parent4b8b48b48572115b943efdf6356a191871d46a55 (diff)
downloadaerogramme-012c6ad6724b6a6e155ee717e6d558e1fe199e43.tar.gz
aerogramme-012c6ad6724b6a6e155ee717e6d558e1fe199e43.zip
initialize aws sdk with our info
Diffstat (limited to 'src/storage/garage.rs')
-rw-r--r--src/storage/garage.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/storage/garage.rs b/src/storage/garage.rs
index f202067..5d00ed6 100644
--- a/src/storage/garage.rs
+++ b/src/storage/garage.rs
@@ -1,5 +1,6 @@
use crate::storage::*;
use serde::Serialize;
+use aws_sdk_s3 as s3;
#[derive(Clone, Debug, Serialize)]
pub struct GarageConf {
@@ -26,9 +27,26 @@ impl GarageBuilder {
}
}
+#[async_trait]
impl IBuilder for GarageBuilder {
- fn build(&self) -> Result<Store, StorageError> {
- unimplemented!();
+ async fn build(&self) -> Result<Store, StorageError> {
+ let creds = s3::config::Credentials::new(
+ self.conf.aws_access_key_id.clone(),
+ self.conf.aws_secret_access_key.clone(),
+ None,
+ None,
+ "aerogramme"
+ );
+
+ let config = aws_config::from_env()
+ .region(aws_config::Region::new(self.conf.region.clone()))
+ .credentials_provider(creds)
+ .endpoint_url(self.conf.s3_endpoint.clone())
+ .load()
+ .await;
+
+ let s3_client = aws_sdk_s3::Client::new(&config);
+ Ok(Box::new(GarageStore { s3: s3_client }))
}
fn unique(&self) -> UnicityBuffer {
UnicityBuffer(self.unicity.clone())
@@ -36,7 +54,7 @@ impl IBuilder for GarageBuilder {
}
pub struct GarageStore {
- dummy: String,
+ s3: s3::Client,
}
#[async_trait]