Skip to content

Commit

Permalink
Added minio uploader for http
Browse files Browse the repository at this point in the history
  • Loading branch information
mburridge96 committed Jun 17, 2024
1 parent 78271e8 commit 0452989
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ url = "2.2"
zip = "0.6.6"
walkdir = "2"
reqwest = { version = "0.11", features = ["blocking", "json"], default-features = false}
log = "0.4.21"
minio = {git="https://github.com/minio/minio-rs.git"}
tokio = "1.38.0"

Expand Down
18 changes: 12 additions & 6 deletions src/ro_crate/transfer/minio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,44 @@ use std::path::Path;

/// Defines minio connection parameters
pub struct MinioParams {
/// URI for Minio
uri: String,
/// URI for Minio (i.e localhost:9000)
pub uri: String,
/// Access key
access: String,
pub access: String,
/// Secret key
secret: String,
pub secret: String,
/// Session token
session: Option<String>,
pub session: Option<String>,
}

/// Currently HTTP insecure, not HTTPS
#[tokio::main]
pub async fn minio_transfer(
crate_path: &Path,
bucket: &str,
conn: &MinioParams,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let base_url = conn.uri.parse::<BaseUrl>()?;
let mut base_url = conn.uri.parse::<BaseUrl>()?;
base_url.https = false;

println!("Trying to connect to MinIO at: `{:?}`", base_url);

let static_provider = StaticProvider::new(&conn.access, &conn.secret, conn.session.as_deref());

let client = ClientBuilder::new(base_url.clone())
.provider(Some(Box::new(static_provider)))
.ignore_cert_check(Some(true))
.build()?;

println!("{:?}", client);

// Check bucket exist or not.
let exists: bool = client
.bucket_exists(&BucketExistsArgs::new(bucket).unwrap())
.await
.unwrap();

println!("Bucker exists? {}", exists);
// Make 'bucket_name' bucket if not exist.
if !exists {
client
Expand Down

0 comments on commit 0452989

Please sign in to comment.