Skip to content

Commit

Permalink
Resolves #35 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleyfowler123 authored and DanielHindi committed Sep 13, 2019
1 parent ce85c49 commit d83c8bf
Showing 1 changed file with 17 additions and 35 deletions.
52 changes: 17 additions & 35 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ var s3 = require('s3');

function S3Zipper(awsConfig) {
var self = this
AWS.config.getCredentials(function (err) {
if (err) {
assert.ok(awsConfig, 'AWS S3 options must be defined.');
assert.notEqual(awsConfig.accessKeyId, undefined, 'Requires S3 AWS Key.');
assert.notEqual(awsConfig.secretAccessKey, undefined, 'Requires S3 AWS Secret');
assert.notEqual(awsConfig.region, undefined, 'Requires AWS S3 region.');
assert.notEqual(awsConfig.bucket, undefined, 'Requires AWS S3 bucket.');
self.init(awsConfig);
} else {
self.init(awsConfig)
}
})
assert.ok(awsConfig, 'AWS S3 options must be defined.');
assert.notEqual(awsConfig.accessKeyId, undefined, 'Requires S3 AWS Key.');
assert.notEqual(awsConfig.secretAccessKey, undefined, 'Requires S3 AWS Secret');
assert.notEqual(awsConfig.region, undefined, 'Requires AWS S3 region.');
assert.notEqual(awsConfig.bucket, undefined, 'Requires AWS S3 bucket.');

AWS.config.update({
accessKeyId: awsConfig.accessKeyId,
secretAccessKey: awsConfig.secretAccessKey,
region: awsConfig.region
});

self.init(awsConfig);
}


Expand All @@ -31,30 +32,11 @@ S3Zipper.prototype = {
init: function (awsConfig) {
this.awsConfig = awsConfig;
var self = this
AWS.config.getCredentials(function (err) {

if (err) {
AWS.config.update({
accessKeyId: awsConfig.accessKeyId,
secretAccessKey: awsConfig.secretAccessKey,
region: awsConfig.region
});
}

if (awsConfig.endpoint) {
AWS.config.update({
endpoint: awsConfig.endpoint
});
self.s3bucket = new AWS.S3({
params: {
Bucket: self.awsConfig.bucket
}

self.s3bucket = new AWS.S3({
params: {
Bucket: self.awsConfig.bucket
}
});

})

});
}
, filterOutFiles: function (fileObj) {
return fileObj;
Expand Down

0 comments on commit d83c8bf

Please sign in to comment.