Skip to content

Commit

Permalink
Added ability to override default region
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbastian-trayio committed Dec 7, 2018
1 parent 830291b commit dfe0a5b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/fileHandler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = function (options) {

//Setup params for `s3.upload` method
var uploadParams = {
Bucket: BUCKET,
Bucket: params.bucket || BUCKET,
Key: fileGuidName,
ContentType: mimeType,
ContentLength: params.length
Expand Down Expand Up @@ -101,7 +101,7 @@ module.exports = function (options) {

}

var s3 = new AWS.S3({ region: REGION });
var s3 = new AWS.S3({ region: params.region || REGION });

s3.upload(uploadParams, function (fileUploadError, data) {

Expand All @@ -116,7 +116,7 @@ module.exports = function (options) {
s3.getSignedUrl(
'getObject',
{
Bucket: BUCKET,
Bucket: params.bucket || BUCKET,
Key: fileGuidName,
Expires: twentyFourHourPeriod.unix() - moment().unix()
},
Expand Down Expand Up @@ -199,7 +199,7 @@ module.exports = function (options) {
var mimeType = params.contentType || mime.lookup(params.name);

var uploadParams = {
Bucket: BUCKET,
Bucket: params.bucket || BUCKET,
Key: fileGuidName,
ContentType: mimeType,
Body: params.readStream
Expand All @@ -209,7 +209,7 @@ module.exports = function (options) {
uploadParams.ContentLength = params.length;
}

var s3 = new AWS.S3({ region: REGION });
var s3 = new AWS.S3({ region: params.region || REGION });

s3.upload(
uploadParams,
Expand All @@ -226,7 +226,7 @@ module.exports = function (options) {
s3.getSignedUrl(
'getObject',
{
Bucket: BUCKET,
Bucket: params.bucket || BUCKET,
Key: fileGuidName,
Expires: twentyFourHourPeriod.unix() - moment().unix()
},
Expand Down

0 comments on commit dfe0a5b

Please sign in to comment.