mirror of
https://github.com/actix/examples
synced 2025-01-22 22:05:57 +01:00
add AWS_REGION env variable and add _ prefix (#270)
* add AWS_REGION env variable and add _ prefix * update indent and remove brackets * remove match code line Co-authored-by: Kai <byeongsangp@tripbtoz.com>
This commit is contained in:
parent
ee0d84fe38
commit
7eaa87f4f1
@ -1,3 +1,4 @@
|
|||||||
AWS_ACCESS_KEY_ID=
|
AWS_ACCESS_KEY_ID=
|
||||||
AWS_SECRET_ACCESS_KEY=
|
AWS_SECRET_ACCESS_KEY=
|
||||||
AWS_S3_BUCKET_NAME=
|
AWS_S3_BUCKET_NAME=
|
||||||
|
AWS_REGION=
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use crate::rusoto_s3::S3;
|
use crate::rusoto_s3::S3;
|
||||||
use rusoto_core::{Region, RusotoError};
|
use rusoto_core::Region;
|
||||||
use rusoto_s3::{DeleteObjectRequest, PutObjectRequest, S3Client};
|
use rusoto_s3::{DeleteObjectRequest, PutObjectRequest, S3Client};
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
pub struct Client {
|
pub struct Client {
|
||||||
region: Region,
|
region: Region,
|
||||||
@ -13,7 +12,7 @@ pub struct Client {
|
|||||||
impl Client {
|
impl Client {
|
||||||
// construct S3 testing client
|
// construct S3 testing client
|
||||||
pub fn new() -> Client {
|
pub fn new() -> Client {
|
||||||
let region = Region::ApNortheast2;
|
let region = Region::default();
|
||||||
|
|
||||||
Client {
|
Client {
|
||||||
region: region.to_owned(),
|
region: region.to_owned(),
|
||||||
@ -26,7 +25,7 @@ impl Client {
|
|||||||
format!(
|
format!(
|
||||||
"https://{}.s3.{}.amazonaws.com/{}",
|
"https://{}.s3.{}.amazonaws.com/{}",
|
||||||
std::env::var("AWS_S3_BUCKET_NAME").unwrap(),
|
std::env::var("AWS_S3_BUCKET_NAME").unwrap(),
|
||||||
"ap-northeast-2",
|
std::env::var("AWS_REGION").unwrap(),
|
||||||
key
|
key
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -41,7 +40,7 @@ impl Client {
|
|||||||
body: Some(contents.into()),
|
body: Some(contents.into()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let res = self
|
let _res = self
|
||||||
.s3
|
.s3
|
||||||
.put_object(put_request)
|
.put_object(put_request)
|
||||||
.await
|
.await
|
||||||
@ -57,7 +56,7 @@ impl Client {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let res = self
|
let _res = self
|
||||||
.s3
|
.s3
|
||||||
.delete_object(delete_object_req)
|
.delete_object(delete_object_req)
|
||||||
.await
|
.await
|
||||||
|
Loading…
x
Reference in New Issue
Block a user