Skip to content

Commit b63e6ac

Browse files
phachemRenat Zubairov
authored andcommitted
aws-s3-component Bug #16 - add region (#17)
Added region to Verification UI and actions and verification code commented listing of empty bucket in the verification because it was throwing an access exception despite access id and secret being correct * draft adding region * don't use bucket during verification * testing bucket file list * log bucket name * add region in verification and in all the actions don't use the bucket during verification
1 parent 94a6fc1 commit b63e6ac

File tree

7 files changed

+15
-4
lines changed

7 files changed

+15
-4
lines changed

component.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
"label": "Secret Access Key",
1414
"required": true,
1515
"viewClass": "TextFieldView"
16+
},
17+
"region": {
18+
"label": "Region",
19+
"required": true,
20+
"viewClass": "TextFieldView"
1621
}
1722
}
1823
},

lib/actions/deleteObject.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ exports.process = async function (msg, cfg) {
66
const s3 = new aws.S3({
77
accessKeyId: cfg.accessKeyId,
88
secretAccessKey: cfg.accessKeySecret,
9+
region: cfg.region
910
});
1011

1112
// eslint-disable-next-line no-param-reassign

lib/actions/getAllFilesInBucket.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ exports.process = async function (msg, cfg) {
66
const s3 = new aws.S3({
77
accessKeyId: cfg.accessKeyId,
88
secretAccessKey: cfg.accessKeySecret,
9+
region: cfg.region
910
});
1011

1112
// eslint-disable-next-line no-param-reassign
1213
cfg.bucketName = msg.body.bucketName ? msg.body.bucketName : cfg.bucketName;
13-
14+
1415
// eslint-disable-next-line no-use-before-define
1516
const data = await s3.listObjects(createAWSInputs(cfg.bucketName)).promise();
1617
data.Contents.forEach((c) => {
@@ -26,5 +27,5 @@ function createAWSInputs(bucketName) {
2627
const bucket = bucketName.substring(0, index);
2728
return { Bucket: bucket, Delimiter: '/', Prefix: folder };
2829
}
29-
return { Bucket: bucketName };
30+
return { Bucket: bucketName } ;
3031
}

lib/actions/readFile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports.process = async function (msg, cfg) {
1111
const s3 = new aws.S3({
1212
accessKeyId: cfg.accessKeyId,
1313
secretAccessKey: cfg.accessKeySecret,
14+
region: cfg.region
1415
});
1516

1617
// eslint-disable-next-line no-param-reassign

lib/actions/streamToCsv.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function processAction(msg, cfg) {
3232
const s3client = new AWS.S3({
3333
accessKeyId: cfg.accessKeyId,
3434
secretAccessKey: cfg.accessKeySecret,
35+
region: cfg.region
3536
});
3637
const streamClient = s3Stream(s3client);
3738
const csv = cfg.csv || {};

lib/actions/streamToFile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports.process = async function (msg, cfg) {
1111
const s3 = new aws.S3({
1212
accessKeyId: cfg.accessKeyId,
1313
secretAccessKey: cfg.accessKeySecret,
14+
region: cfg.region
1415
});
1516

1617
// eslint-disable-next-line no-param-reassign

verifyCredentials.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ module.exports = function verifyCredentials(credentials, cb) {
1616
const s3 = new aws.S3({
1717
accessKeyId: credentials.accessKeyId,
1818
secretAccessKey: credentials.accessKeySecret,
19+
region: credentials.region
1920
});
2021

2122
// eslint-disable-next-line no-use-before-define
22-
const data = await s3.listObjects({ Bucket: '' }).promise();
23-
debug('Root dir files: %j', data.Contents.forEach(c => c.Key));
23+
//const data = await s3.listObjects({ Bucket: '' }).promise();
24+
//debug('Root dir files: %j', data.Contents.forEach(c => c.Key));
2425
console.log('Verification completed');
2526

2627
cb(null, { verified: true });

0 commit comments

Comments
 (0)