A s3 handler library for s3rs and nu-shell s3 plugin Here is the document.
use s3handler = { features = ["blocking"] }
rust
let config = s3handler::CredentialConfig{
host: "s3.us-east-1.amazonaws.com".to_string(),
access_key: "akey".to_string(),
secret_key: "skey".to_string(),
user: None,
region: None, // default will be treated as us-east-1
s3_type: None, // default will try to config as AWS S3 handler
secure: None, // dafault is false, because the integrity protect by HMAC
};
let mut handler = s3handler::Handler::from(&config);
let _ = handler.la();
Basic CRUD is implemented, other advance features are under developing. use s3handler = { features = ["tokio"] }
Download a file with async api use s3handler = { features = ["tokio-async"] } ```rust // Public resource let s3pool = s3handler::noneblocking::primitives::S3Pool::new("somewhere.in.the.world".tostring()); let obj = s3pool.bucket("bucketname").object("objcetname"); async { obj.download_file("/path/to/save/a/file").await; };
```
S3 async handler to manipulate objects and buckets. This treat all data as pool and create a canal to bridge two pool. It is easy to management and sync data from folder to S3, S3 to S3, event folder to folder.
> +------+ | Pool | (UpPool) modify by
from_*
api +------+ | ^ Pull | | Push v | +------+ | Pool | (DownPool) modify bytoward_*
api +------+ >
```rust use s3handler::none_blocking::traits::DataPool;
// Resource with AWS version 2 auth let s3pool = s3handler::noneblocking::primitives::S3Pool::new("somewhere.in.the.world".tostring()) .awsv2("access-key".tostring(), "secrete-key".tostring()); let bucket = s3pool.bucket("bucketname"); // Actually the bucket is a unconnnected canal assert!(!bucket.isconnect()); let canal = bucket.toward("/path/to/another/folder").unwrap(); // The canal bridges the two folder and ready to transfer data between bucket and folder assert!(canal.isconnect()); canal.sync().await;
let s3pool = S3Pool::new(env::var("S3HOST").unwrap()).awsv4( akey.tostring(), env::var("SECRETKEY").unwrap(), env::var("REGION").unwrap(), ); let mut objectlist = s3pool .bucket(&env::var("BUCKETNAME").unwrap()) .list() .await .unwrap(); let obj = objectlist.nextobject().await.unwrap(); ```