cloud-storage-lite

A simple, flexible Google Cloud Storage client (GCS).

This library isn't as featureful as, say the cloud-storage crate, but it's also more usable if you: * are using a secret keeper like Vault * generally work with a single bucket (using a bucket-scoped client) * would like to use multiple clients or tokio runtimes in one program * want canonicalized errors (404 gets one and only one error variant) * want to mock the GCP interfaces in tests (after enabling the mocks feature)

Example

```rust use std::{error::Error, convert::Infallible}; use cloudstoragelite::{ self as gcs, BucketClient, token_provider::{ self, oauth::{self, OAuthTokenProvider, ServiceAccount}}, }; use futures::{future, stream, TryStreamExt};

[tokio::main]

async fn main() -> Result<(), Box> { let tokenprovider = tokenprovider::RenewingTokenProvider::new( OAuthTokenProvider::new( ServiceAccount::readfromcanonicalenv()?, oauth::SCOPESTORAGEFULLCONTROL, )? ); let client = gcs::Client::new(tokenprovider) .intobucket_client("my-bucket".into());

client .createobject( "key", stream::once( future::ok::<_, Infallible>(b"value".tovec()) ) ) .await?;

let object = client.get_object("key").await?;

let valuebytes = client .downloadobject(&object.name) .await? .mapok(|chunk| chunk.tovec()) .try_concat() .await?;

println!( "the value is: {}", String::fromutf8(valuebytes)? );

Ok(()) } ```