use crate::error::{Error, Result};
use object_store::aws::AmazonS3Builder;
use object_store::ObjectStore;
use std::sync::Arc;
pub fn build_s3_store(
endpoint: &str,
region: &str,
access_key: &str,
secret_key: &str,
bucket_name: &str,
) -> Result<Arc<dyn ObjectStore>> {
let store = AmazonS3Builder::new()
.with_endpoint(endpoint)
.with_region(region)
.with_access_key_id(access_key)
.with_secret_access_key(secret_key)
.with_bucket_name(bucket_name)
.build()
.map_err(Error::ObjectStore)?;
Ok(Arc::new(store))
}
pub fn build_s3_store_from_env(bucket_name: &str) -> Result<Arc<dyn ObjectStore>> {
let store = AmazonS3Builder::from_env()
.with_bucket_name(bucket_name)
.build()
.map_err(Error::ObjectStore)?;
Ok(Arc::new(store))
}