Skip to content

Commit

Permalink
Resolve correct url for us-east-1 AWS region
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Kristian Flaatten committed Jun 11, 2015
1 parent 04c718f commit 86131a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ Upload = module.exports = (awsBucketName, @opts = {}) ->
@opts.tmpPrefix ?= 'gm-'

@opts.workers ?= 1
@opts.url ?= "https://s3-#{@opts.aws.region}.amazonaws.com/#{@opts.aws.params.Bucket}/"

if not @opts.url and @opts.aws.region is 'us-east-1'
@opts.url ?= "https://s3.amazonaws.com/#{@opts.aws.params.Bucket}/"
else if not @opts.url
@opts.url ?= "https://s3-#{@opts.aws.region}.amazonaws.com/#{@opts.aws.params.Bucket}/"

@s3 = new S3 @opts.aws

Expand Down
2 changes: 1 addition & 1 deletion test/suite.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe 'Upload', ->
assert.equal upload.opts.tmpPrefix, 'gm-'

assert.equal upload.opts.workers, 1
assert.equal upload.opts.url, 'https://s3-us-east-1.amazonaws.com/myBucket/'
assert.equal upload.opts.url, 'https://s3.amazonaws.com/myBucket/'

it 'should set deprecated options correctly', ->
upload = new Upload 'myBucket',
Expand Down

0 comments on commit 86131a9

Please sign in to comment.