Skip to content

Commit ea56804

Browse files
committed
Allow any creation with an ObjectStore
1 parent 089096c commit ea56804

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ jobs:
1414
format:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1818
- run: cargo fmt --all -- --check
1919

2020
# no cache needed for cargo outdated
2121
outdated:
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v3
25-
- run: cargo install cargo-outdated
24+
- uses: actions/checkout@v4
25+
- run: cargo install --locked cargo-outdated
2626
- run: cargo outdated --exit-code 1
2727

2828
build:
2929
runs-on: ubuntu-latest
3030
steps:
31-
- uses: actions/checkout@v3
31+
- uses: actions/checkout@v4
3232
- uses: Swatinem/rust-cache@v2
3333
with:
3434
prefix-key: cargo
@@ -38,7 +38,7 @@ jobs:
3838
clippy:
3939
runs-on: ubuntu-latest
4040
steps:
41-
- uses: actions/checkout@v3
41+
- uses: actions/checkout@v4
4242
- uses: Swatinem/rust-cache@v2
4343
with:
4444
prefix-key: cargo
@@ -48,7 +48,7 @@ jobs:
4848
test:
4949
runs-on: ubuntu-latest
5050
steps:
51-
- uses: actions/checkout@v3
51+
- uses: actions/checkout@v4
5252
- uses: Swatinem/rust-cache@v2
5353
with:
5454
prefix-key: cargo

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Easy-to-use library to create image thumbnails from images existing on some (cloud) object storage or from disk.
44

5-
Currently implemented is a connection to Google Cloud Storage, but it can be easily extended to other providers.
5+
Works with any storage provider that is supported by [`object_store`](https://crates.io/crates/object_store).
66

77
## Supported formats
88
PNG and JPEG are currently the only supported image formats.
@@ -28,7 +28,6 @@ thumbs:
2828
2929
## Google credentials
3030
This crate relies on [object_store](https://crates.io/crates/object_store) for the interaction with the storage backend.
31-
Currently, this crate only supports Google Cloud Storage and AWS S3.
3231
3332
To configure the Google Service Account, use one of the following environment variables as
3433
[described in the object_store](https://docs.rs/object_store/latest/object_store/gcp/struct.GoogleCloudStorageBuilder.html#method.from_env)

src/model.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use image::ImageFormat;
2+
use object_store::ObjectStore;
23
use object_store::path::Path;
34
use serde::Deserialize;
45
use std::sync::Arc;
@@ -10,6 +11,18 @@ pub struct ImageThumbs<T> {
1011
pub(crate) settings: Arc<Vec<Params>>,
1112
}
1213

14+
impl<T> ImageThumbs<T> {
15+
pub fn with_store(object_store: T, settings: Vec<Params>) -> Self
16+
where
17+
T: ObjectStore,
18+
{
19+
Self {
20+
client: Arc::new(RwLock::new(object_store)),
21+
settings: Arc::new(settings),
22+
}
23+
}
24+
}
25+
1326
impl<T> Clone for ImageThumbs<T> {
1427
fn clone(&self) -> Self {
1528
Self {

0 commit comments

Comments
 (0)