Try it #1
@@ -1,5 +1,8 @@
|
|||||||
|
#[derive(Default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub url: String,
|
pub url: String,
|
||||||
pub bucket: String,
|
pub bucket: String,
|
||||||
pub region: String,
|
pub region: String,
|
||||||
|
pub access_key_id: String,
|
||||||
|
pub secret_key: String
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-1
@@ -1,5 +1,7 @@
|
|||||||
pub mod config;
|
pub mod config;
|
||||||
|
|
||||||
|
use aws_sdk_s3::config::{Credentials, Region};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Data {
|
pub struct Data {
|
||||||
pub filepath: String,
|
pub filepath: String,
|
||||||
@@ -25,7 +27,24 @@ impl Labyrinth {
|
|||||||
file_key: &str,
|
file_key: &str,
|
||||||
data: &Data,
|
data: &Data,
|
||||||
) -> Result<aws_sdk_s3::operation::put_object::PutObjectOutput, Error> {
|
) -> Result<aws_sdk_s3::operation::put_object::PutObjectOutput, Error> {
|
||||||
let config = aws_config::load_from_env().await;
|
// 1. Create credentials
|
||||||
|
let credentials = Credentials::new(
|
||||||
|
self.config.access_key_id.clone(),
|
||||||
|
self.config.secret_key.clone(),
|
||||||
|
None, // session_token - None for long-term credentials
|
||||||
|
None, // expires_after - None for long-term credentials
|
||||||
|
"maze", // provider_name - just a label
|
||||||
|
);
|
||||||
|
|
||||||
|
// 2. Create region
|
||||||
|
let region = Region::new(self.config.region.to_string());
|
||||||
|
let config = aws_config::from_env()
|
||||||
|
.region(region)
|
||||||
|
.credentials_provider(credentials)
|
||||||
|
.load()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
// let config = aws_config::load_from_env().await;
|
||||||
let client = aws_sdk_s3::Client::new(&config);
|
let client = aws_sdk_s3::Client::new(&config);
|
||||||
|
|
||||||
let data_content = if data.raw_data.is_empty() {
|
let data_content = if data.raw_data.is_empty() {
|
||||||
|
|||||||
Reference in New Issue
Block a user