added new method to s3clientconfig struct, added from_env to be default
This commit is contained in:
@@ -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<Self, Box<dyn std::error::Error>> {
|
||||
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<Self, Box<dyn std::error::Error>> {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user