google-cloud-storage

Google Cloud Platform Storage Client library.

Installation

[dependencies] google-cloud-storage = <version>

Quick Start

```rust use googlecloudstorage::client::Client; use googlecloudstorage::client::http::Error; use googlecloudstorage::sign::SignedURLOptions; use googlecloudstorage::sign::SignedURLMethod; use googlecloudstorage::http::objects::download::Range; use googlecloudstorage::http::objects::get::GetObjectRequest; use googlecloudstorage::http::objects::upload::UploadObjectRequest; use tokio::task::JoinHandle; use std::fs::File; use std::io::BufReader; use std::io::Read;

[tokio::main]

async fn main() -> Result<(), Error> {

// Create client.
let mut client = Client::default().await.unwrap();

// Upload the file
let uploaded = client.upload_object(&UploadObjectRequest {
    bucket: "bucket".to_string(),
    name: "file.png".to_string(),
    ..Default::default()
}, "hello world".as_bytes(), "application/octet-stream", None).await;

// Download the file
let data = client.download_object(&GetObjectRequest {
    bucket: "bucket".to_string(),
    object: "file.png".to_string(),
    ..Default::default()

}, &Range::default(), None).await;

// Create signed url.
let url_for_download = client.signed_url("bucket", "foo.txt", SignedURLOptions::default());
let url_for_upload = client.signed_url("bucket", "foo.txt", SignedURLOptions {
    method: SignedURLMethod::PUT,
    ..Default::default()
});
Ok(())

} ```