minio-rsc

Crates.io Documentation License

Rust Library for Minio. API is compliant with the Amazon S3 protocol.

Minio client

```rust use miniorsc::client::{BucketArgs, KeyArgs}; use miniorsc::error::Result; use miniorsc::provider::StaticProvider; use miniorsc::Minio;

async fn example() -> Result<()> { let provider = StaticProvider::new("minio-access-key-test", "minio-secret-key-test", None); let minio = Minio::builder() .endpoint("localhost:9022") .provider(provider) .secure(false) .build() .unwrap(); let (buckets, owner) = minio.list_buckets().await?;

minio.make_bucket(BucketArgs::new("bucket1"), false).await?;
minio.make_bucket("bucket2", true).await?;

minio.put_object("bucket1", "hello.txt", "hello minio!".into()).await?;
minio.stat_object("bucket1", "hello.txt").await?;
minio.get_object("bucket1", "hello.txt").await?;
let key = KeyArgs::new("hello.txt").version_id(Some("cdabf31a-9752-4265-b137-6b3961fbaf9b".to_string()));
minio.get_object("bucket1", key).await?;
minio.remove_object("bucket1", "hello.txt").await?;

let bucket2 = minio.bucket("bucket2");
bucket2.put_object("hello.txt", "hello minio!".into()).await?;
bucket2.stat_object("hello.txt").await?;
bucket2.get_object("hello.txt").await?;
bucket2.remove_object("hello.txt").await?;

// if fs-tokio feature enabled
// download file to local
minio.fget_object("bucket1", "hello.txt", "local.txt").await?;
// upload file to minio
minio.fput_object("bucket1", "hello.txt", "local.txt").await?;

minio.remove_bucket("bucket1").await?;
minio.remove_bucket("bucket2").await?;

Ok(())

} ```

Operations

| Bucket operations | Object operations | |-|-| | makebucket | getobject | | listbuckets | fgetobject | | bucketexists | copyobject | | removebucket | statobject | | listobjects | removeobject | | getbuckettags | putobject | | setbuckettags | fputobject | | deletebuckettags | presignedgetobject | | getbucketversioning | presignedputobject | | setbucketversioning | isobjectlegalholdenabled | | getobjectlockconfig | enableobjectlegalholdenabled | | setobjectlockconfig | disableobjectlegalholdenabled | | deleteobjectlockconfig | getobjecttags | | | setobjecttags | | | deleteobjecttags | | | getobjectretention | | | setobjectretention | | | selectobject_content | | | |

Features

Custom requests

Implemented by BaseExecutor

```rust use miniorsc::Minio; use hyper::Method; use miniorsc::errors::Result; use reqwest::Response; use bytes::Bytes;

async fn getobject(minio:Minio)-> Result { let executor = minio.executor(Method::GET); let res: Response = executor .bucketname("bucket") .objectname("test.txt") .query("versionId", "cdabf31a-9752-4265-b137-6b3961fbaf9b") .sendok() .await?; Ok(res) }

async fn putobject(minio:Minio, data:Bytes)-> Result<()> { let executor = minio.executor(Method::PUT); let res: Response = executor .bucketname("bucket") .objectname("test.txt") .body(data) .sendok() .await?; Ok(()) } ```