File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ use error::Result;
14
14
use failure:: err_msg;
15
15
use rusoto_s3:: { S3 , PutObjectRequest , GetObjectRequest , S3Client } ;
16
16
use rusoto_core:: region:: Region ;
17
- use rusoto_credential:: EnvironmentProvider ;
17
+ use rusoto_credential:: DefaultCredentialsProvider ;
18
18
19
19
20
20
fn get_file_list_from_dir < P : AsRef < Path > > ( path : P ,
@@ -115,12 +115,19 @@ pub fn get_path(conn: &Connection, path: &str) -> Option<Blob> {
115
115
fn s3_client ( ) -> Option < S3Client > {
116
116
// If AWS keys aren't configured, then presume we should use the DB exclusively
117
117
// for file storage.
118
- if std:: env:: var_os ( "AWS_ACCESS_KEY_ID" ) . is_none ( ) {
118
+ if std:: env:: var_os ( "AWS_ACCESS_KEY_ID" ) . is_none ( ) && std :: env :: var_os ( "FORCE_S3" ) . is_none ( ) {
119
119
return None ;
120
120
}
121
+ let creds = match DefaultCredentialsProvider :: new ( ) {
122
+ Ok ( creds) => creds,
123
+ Err ( err) => {
124
+ warn ! ( "failed to retrieve AWS credentials: {}" , err) ;
125
+ return None ;
126
+ }
127
+ } ;
121
128
Some ( S3Client :: new_with (
122
129
rusoto_core:: request:: HttpClient :: new ( ) . unwrap ( ) ,
123
- EnvironmentProvider :: default ( ) ,
130
+ creds ,
124
131
std:: env:: var ( "S3_ENDPOINT" ) . ok ( ) . map ( |e| Region :: Custom {
125
132
name : "us-west-1" . to_owned ( ) ,
126
133
endpoint : e,
You can’t perform that action at this time.
0 commit comments