File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,11 @@ import Uploader from 's3-batch-upload';
7070
7171const files = await new Uploader ({
7272 config: ' ./config/configS3.json' , // can also use environment variables
73+ config: { // or you can use a object
74+ accessKeyId: " __EMPTY__" ,
75+ secretAccessKey: " __EMPTY__" ,
76+ region: " us-east-1"
77+ },
7378 bucket: ' bucket-name' ,
7479 localPath: ' ./files' ,
7580 remotePath: ' remote/path/in/bucket' ,
Original file line number Diff line number Diff line change 11import streamBatch from './batch' ;
22import S3 from 'aws-sdk/clients/s3' ;
3+ import { ConfigurationOptions } from 'aws-sdk/lib/config' ;
34
45const glob = require ( 'glob' ) ;
56const minimatch = require ( 'minimatch' ) ;
@@ -15,7 +16,7 @@ export type Options = {
1516 bucket : string ;
1617 localPath : string ;
1718 remotePath : string ;
18- config ?: string ;
19+ config ?: string | ConfigurationOptions ;
1920 glob ?: string ;
2021 globOptions ?: object ;
2122 concurrency ?: number ;
@@ -46,7 +47,13 @@ export default class Uploader {
4647 } ;
4748
4849 if ( this . options . config ) {
49- AWS . config . loadFromPath ( this . options . config ) ;
50+ if ( typeof this . options . config === 'string' ) {
51+ AWS . config . loadFromPath ( this . options . config ) ;
52+ } else if ( typeof this . options . config === 'object' ) {
53+ AWS . config . constructor ( this . options . config ) ;
54+ } else {
55+ throw new Error ( 'unsupported config is passed as a argument.' ) ;
56+ }
5057 }
5158
5259 // TODO: more checks on other options?
You can’t perform that action at this time.
0 commit comments