From 26732be4b28f7b3d38e3aaaca396da6e8e909ef8 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Fri, 16 Aug 2019 18:22:03 -0300 Subject: [PATCH] Got some pieces from S4 and now we can list stuff --- Cargo.lock | 1 + Cargo.toml | 1 + src/main.rs | 18 +++++++++++++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 19707ea..adc4973 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -648,6 +648,7 @@ name = "nc-dirs" version = "0.1.0" dependencies = [ "rusoto_core 0.40.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rusoto_credential 0.40.0 (registry+https://github.com/rust-lang/crates.io-index)", "rusoto_s3 0.40.0 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.toml b/Cargo.toml index 243bebc..50af7bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,4 @@ edition = "2018" [dependencies] rusoto_s3 = "0.40.0" rusoto_core = "0.40.0" +rusoto_credential = "0.40.0" diff --git a/src/main.rs b/src/main.rs index 9d11759..4660558 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,25 +1,33 @@ use std::env; use rusoto_core::Region; -use rusoto_s3::S3Client; +use rusoto_credential::StaticProvider; +use rusoto_core::request::HttpClient; use rusoto_s3::ListObjectsV2Request; use rusoto_s3::S3; +use rusoto_s3::S3Client; fn main() { - let region = env::var("NC_REGION").expect("export NC_REGION with the endpoint region"); + let region_name = env::var("NC_REGION").expect("export NC_REGION with the endpoint region"); let endpoint = env::var("NC_ENDPOINT").expect("export NC_ENDPOINT with the endpot URL"); let bucket = env::var("NC_BUCKET").expect("export NC_BUCKET with the bucket to be accessed"); + let access_key = env::var("NC_ACCESS_KEY").expect("export NC_ACCESS_KEY with the access key to the bucket"); + let secret_key = env::var("NC_SECRET_KEY").expect("export NC_SECRET_KEY with the secret key to the bucket"); println!("Accessing {}::{}", - region, + region_name, endpoint); let region = Region::Custom { - name: region.to_owned(), + name: region_name.to_owned(), endpoint: endpoint.to_owned() }; - let client = S3Client::new(region); + let client = S3Client::new_with( + HttpClient::new().expect("Failed to create http client"), + StaticProvider::new_minimal(access_key, secret_key), + region + ); let list_objects_request = ListObjectsV2Request { bucket: bucket.to_owned(),