Comparing version 0.0.7 to 0.0.8
26
aws3.js
@@ -13,3 +13,3 @@ /* jshint laxcomma: true */ | ||
Aws3.s3Bucket = process.env.S3_BUCKET || 'aws3_bucket'; | ||
Aws3.region = process.env.AWS_REGION || 's3'; | ||
Aws3.awsRegion = process.env.AWS_REGION || 'us-east-1'; | ||
@@ -33,2 +33,3 @@ | ||
this.asattachment = false; // must be explicitly set eg. aws3.asattachment = true; | ||
this.awsregion = Aws3.awsRegion; | ||
} | ||
@@ -107,4 +108,25 @@ | ||
Aws3.prototype.regionExtension = function() { | ||
if (this.awsregion !== 'us-east-1') { | ||
return '-'+this.awsregion; | ||
} | ||
return ''; | ||
}; | ||
/* | ||
* @api private | ||
*/ | ||
Aws3.prototype.subdomain = function() { | ||
return 's3'+this.regionExtension(); | ||
}; | ||
/* | ||
* @api private | ||
*/ | ||
Aws3.prototype.s3Url = function() { | ||
return 'https://'+Aws3.region+'.amazonaws.com/'+Aws3.s3Bucket; | ||
return 'https://'+this.subdomain()+'.amazonaws.com/'+Aws3.s3Bucket; | ||
}; | ||
@@ -111,0 +133,0 @@ |
{ | ||
"name": "aws3.js", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Simple AWS S3 Generator", | ||
@@ -5,0 +5,0 @@ "main": "aws3.js", |
@@ -143,2 +143,32 @@ /* jshint laxcomma: true */ | ||
}); | ||
describe('alternate regions', function() { | ||
it('defaults to the us-east-1 region', function() { | ||
var aws3 = new Aws3('large.txt', 'text/plain'); | ||
assert.equal(aws3.subdomain(), 's3'); | ||
var aws32 = new Aws3('large.txt', 'text/plain'); | ||
aws32.awsregion = 'us-east-1'; | ||
assert.equal(aws32.subdomain(), 's3'); | ||
}); | ||
it('can have the region set globally', function() { | ||
Aws3.awsRegion = 'us-west-2'; | ||
var aws3 = new Aws3('large.txt', 'text/plain'); | ||
assert.equal(aws3.subdomain(), 's3-us-west-2'); | ||
var aws32 = new Aws3('large.txt', 'text/plain'); | ||
assert.equal(aws32.subdomain(), 's3-us-west-2'); | ||
}); | ||
it('can have the region set for each instance', function() { | ||
var aws3 = new Aws3('large.txt', 'text/plain'); | ||
aws3.awsregion = 'us-west-2'; | ||
assert.equal(aws3.subdomain(), 's3-us-west-2'); | ||
var aws32 = new Aws3('large.txt', 'text/plain'); | ||
aws32.awsregion = 'us-west-3'; | ||
assert.equal(aws32.subdomain(), 's3-us-west-3'); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9232
269