1
0
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:
ggomagundan 2020-03-20 09:21:58 +09:00 committed by GitHub
parent ee0d84fe38
commit 7eaa87f4f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -1,3 +1,4 @@
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_S3_BUCKET_NAME=
AWS_S3_BUCKET_NAME=
AWS_REGION=

View File

@ -1,8 +1,7 @@
use crate::rusoto_s3::S3;
use rusoto_core::{Region, RusotoError};
use rusoto_core::Region;
use rusoto_s3::{DeleteObjectRequest, PutObjectRequest, S3Client};
use std::io::Read;
use std::io::Write;
pub struct Client {
region: Region,
@ -13,7 +12,7 @@ pub struct Client {
impl Client {
// construct S3 testing client
pub fn new() -> Client {
let region = Region::ApNortheast2;
let region = Region::default();
Client {
region: region.to_owned(),
@ -26,7 +25,7 @@ impl Client {
format!(
"https://{}.s3.{}.amazonaws.com/{}",
std::env::var("AWS_S3_BUCKET_NAME").unwrap(),
"ap-northeast-2",
std::env::var("AWS_REGION").unwrap(),
key
)
}
@ -41,7 +40,7 @@ impl Client {
body: Some(contents.into()),
..Default::default()
};
let res = self
let _res = self
.s3
.put_object(put_request)
.await
@ -57,7 +56,7 @@ impl Client {
..Default::default()
};
let res = self
let _res = self
.s3
.delete_object(delete_object_req)
.await