From 0452989d4f5506049a423549ab574b0d059e7a4a Mon Sep 17 00:00:00 2001 From: Matt Burridge Date: Mon, 17 Jun 2024 18:02:49 +0100 Subject: [PATCH] Added minio uploader for http --- Cargo.lock | 1 - Cargo.toml | 1 - src/ro_crate/transfer/minio.rs | 18 ++++++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e464ec5..e26ae67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1300,7 +1300,6 @@ name = "ro-crate-rs" version = "0.1.0" dependencies = [ "chrono", - "log", "minio", "rand", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index 08ce75b..fa4ab7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/ro_crate/transfer/minio.rs b/src/ro_crate/transfer/minio.rs index e2bee3a..cbb2c8e 100644 --- a/src/ro_crate/transfer/minio.rs +++ b/src/ro_crate/transfer/minio.rs @@ -8,23 +8,25 @@ 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, + pub session: Option, } +/// Currently HTTP insecure, not HTTPS #[tokio::main] pub async fn minio_transfer( crate_path: &Path, bucket: &str, conn: &MinioParams, ) -> Result<(), Box> { - let base_url = conn.uri.parse::()?; + let mut base_url = conn.uri.parse::()?; + base_url.https = false; println!("Trying to connect to MinIO at: `{:?}`", base_url); @@ -32,14 +34,18 @@ pub async fn minio_transfer( 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