#google #cloud #storage


A crate for uploading files to Google cloud storage, and for generating download urls

11 releases

✓ Uses Rust 2018 edition

0.2.4 Dec 17, 2019
0.2.3 Dec 16, 2019
0.1.5 Oct 25, 2019

#247 in Web programming

Download history 9/week @ 2020-02-06 41/week @ 2020-02-13 23/week @ 2020-02-20 45/week @ 2020-02-27 23/week @ 2020-03-05 13/week @ 2020-03-12 44/week @ 2020-03-19 19/week @ 2020-03-26 2/week @ 2020-04-02 48/week @ 2020-04-09 46/week @ 2020-04-16 1/week @ 2020-04-23 1/week @ 2020-04-30 2/week @ 2020-05-07 1/week @ 2020-05-14 3/week @ 2020-05-21

118 downloads per month

MIT license

366 lines

Cloud Storage

cloud-storage-rs on crates.io stripe-rust on docs.rs

A library that can be used to push blobs to Google Cloud Storage, and then generate download links to those files:

// create a new Bucket
let bucket = Bucket::create("mybucket").unwrap();
// upload a file to our new bucket
bucket.upload(b"Your file is now on google cloud storage!", "folder/filename.txt", "application/text").unwrap();
// let's rename the file
bucket.update("folder/filename.txt", "new filename.txt").unwrap();
// print a link to the file
println!("{}", bucket.download_url("new filename.txt", 1000)); // download link for 1000 seconds
// remove the file from the bucket

Authorization can be granted using the SERVICE_ACCOUNT environment variable, which should contain path to the service-account-*******.json file that contains the Google credentials. The service account requires the permission devstorage.full_control. This is not strictly necessary, so if you need this fixed, let me know!

The service account should also have the roles Service Account Token Creator (for generating access tokens) and Storage Object Admin (for generating sign urls to download the files).

The exposed API is very bare-bones right now, only allowing storing, reading, moving and deleting. Feel free to open up a pull request is you need more complete support, it shouldn't be too much work to add more endpoints.


~639K SLoC