diff --git a/Cargo.toml b/Cargo.toml index cdf25a0..a10cba4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "image_thumbs" -version = "0.2.0" +version = "0.2.1" edition = "2021" repository = "https://github.com/tweedegolf/image-thumbs" keywords = ["GCS", "image", "thumbnails"] diff --git a/src/gcs.rs b/src/gcs.rs index acd110c..a4e72f5 100644 --- a/src/gcs.rs +++ b/src/gcs.rs @@ -1,5 +1,6 @@ use object_store::gcp::{GoogleCloudStorage, GoogleCloudStorageBuilder}; +use crate::model::Params; use crate::{ImageThumbs, ThumbsResult}; impl ImageThumbs { @@ -26,4 +27,12 @@ impl ImageThumbs { settings: Self::settings(config)?, }) } + + pub async fn new_with_settings(settings: Vec) -> ThumbsResult { + let client = GoogleCloudStorageBuilder::from_env() + .with_client_options(Self::client_options()) + .build()?; + + Ok(Self { client, settings }) + } } diff --git a/src/model.rs b/src/model.rs index 25cb838..3659210 100644 --- a/src/model.rs +++ b/src/model.rs @@ -9,7 +9,7 @@ pub struct ImageThumbs { } #[derive(Deserialize, Debug, Clone)] -pub(crate) struct Params { +pub struct Params { /// Can be used as `{thumb_name}` in the `naming_pattern`. /// If the naming_pattern is not explicitly given, the default is /// "`/{thumb_name}/{image_name}.{image_extension}`"