From 29011c8f48be2410e68d5d06edab24ef8f989808 Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Mon, 14 Jul 2025 18:21:13 -0400 Subject: [PATCH] added new method to s3clientconfig struct, added from_env to be default --- backend/storage/src/services/aws.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/backend/storage/src/services/aws.rs b/backend/storage/src/services/aws.rs index aae82d0..237b088 100644 --- a/backend/storage/src/services/aws.rs +++ b/backend/storage/src/services/aws.rs @@ -18,6 +18,22 @@ pub struct S3Client { } impl S3ClientConfig { + pub fn new( + access_key: &str, + secret_key: &str, + endpoint: &str, + bucket: &str, + region: &str, + ) -> Result> { + Ok(S3ClientConfig { + access_key: access_key.to_owned(), + secret_key: secret_key.to_owned(), + endpoint: endpoint.to_owned(), + bucket: bucket.to_owned(), + region: region.to_owned(), + }) + } + pub fn from_env() -> Result> { Ok(S3ClientConfig { access_key: env::var("S3_ACCESS_KEY") @@ -99,3 +115,9 @@ impl ObjectStorageClient for S3Client { todo!("not impl") } } + +impl Default for S3ClientConfig { + fn default() -> Self { + S3ClientConfig::from_env().unwrap() + } +}