Add the following line to your Cargo.toml
rust
[dependencies]
waihona = "0.0.1"
Rust library for cloud storage across major cloud providers It aims to provide simple to use functions to perform CRUD operations on buckets and blobs. Waihona simply means storage in Hawaiian
## Feature Flags
The following feature flags exist for this crate
- [x] aws
: Enable aws provider and dependencies
- [x] gcp
: Enable gcp provider and dependencies
- [] azure
: Enable azure provider and dependencies
These quick examples will show you how to make use of the library for basic actions
List buckets from project waihona on GCP
```rust // ensure to export service credential using GOOGLEAPPLICATIONCREDENTIALS
use waihona::providers::gcp::GcpBucket;
async fn testlistbuckets() -> Vec
Check bucket waihona exists on AWS
```rust
async fn testbucketexists() -> bool { use waihona::types::bucket::{Buckets}; use waihona::providers; let mut awsbuckets = providers::aws::AwsBuckets::new( "us-east-2" ); let resp = awsbuckets.exists( "waihona" ).await; // OR you can do let resp = providers::aws::AwsBucket::exists( "us-east-2", "waihona" ).await; resp } ```
Write content to a blob "example.txt" in waihona bucket on Azure
```rust
use waihona::providers::azure::AzureBlob;
async fn testcreateblob() -> AzureBlob { // !! UNIMPLEMENTED use waihona::types::bucket::{Buckets, Bucket}; use waihona::types::blob::{Blob}; use waihona::providers; use bytes::Bytes; let mut azurebuckets = providers::azure::AzureBuckets::new(); let waihona = azurebuckets.open( "waihona", ).await.unwrap(); let mut blob = waihona.write_blob( "example.txt", Some(Bytes::from("Hello world")) ).await .unwrap(); blob } ```
Copy file content from "example.txt" blob on AWS to blob on GCP and delete AWS blob afterwards assuming waihona buckets exist on both platforms
```rust
use waihona::providers::gcp::GcpBlob;
async fn testtransferblob() -> GcpBlob { use waihona::types::bucket::{Buckets, Bucket}; use waihona::types::blob::{Blob}; use waihona::providers; use bytes::Bytes; let mut awsblob = providers::aws::AwsBlob::get( "us-east-2", // Region "waihona", // Bucket name "example.txt", // Blob name None // Content range ).await .unwrap(); let mut gcpblob = providers::gcp::GcpBlob::get( "gcp-project-name", // Project name "waihona", // Bucket name "example.txt", // Blob name None // Content range ).await .unwrap(); let content: Bytes = awsblob.read().unwrap(); gcpblob.write(Some(content)).await.unwrap(); awsblob.delete().unwrap(); gcpblob } ```
This project is opened under the MIT License which allows very broad use for both academic and commercial purposes