Comparing version 1.3.0 to 2.0.0
19
index.js
@@ -31,2 +31,3 @@ var AWS = require('aws-sdk'); | ||
exports.getPublicUrl = getPublicUrl; | ||
exports.getPublicUrlHttp = getPublicUrlHttp; | ||
@@ -924,11 +925,17 @@ exports.Client = Client; | ||
function ensureLeadingSlash(filename) { | ||
return filename[0] !== '/' ? '/' + filename : filename; | ||
function getPublicUrl(bucket, key, bucketLocation) { | ||
var hostnamePrefix = bucketLocation ? ("s3-" + bucketLocation) : "s3"; | ||
var parts = { | ||
protocol: "https:", | ||
hostname: hostnamePrefix + ".amazonaws.com", | ||
pathname: "/" + bucket + "/" + encodeSpecialCharacters(key), | ||
}; | ||
return url.format(parts); | ||
} | ||
function getPublicUrl(bucket, key, insecure) { | ||
function getPublicUrlHttp(bucket, key) { | ||
var parts = { | ||
protocol: insecure ? "http:" : "https:", | ||
hostname: "s3.amazonaws.com", | ||
pathname: "/" + bucket + encodeSpecialCharacters(ensureLeadingSlash(key)), | ||
protocol: "http:", | ||
hostname: bucket + ".s3.amazonaws.com", | ||
pathname: "/" + encodeSpecialCharacters(key), | ||
}; | ||
@@ -935,0 +942,0 @@ return url.format(parts); |
{ | ||
"name": "s3", | ||
"version": "1.3.0", | ||
"version": "2.0.0", | ||
"description": "high level amazon s3 client. upload and download files and directories", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -153,8 +153,19 @@ # High Level Amazon S3 Client | ||
### s3.getPublicUrl(bucket, key, [insecure]) | ||
### s3.getPublicUrl(bucket, key, [bucketLocation]) | ||
* `bucket` S3 bucket | ||
* `key` S3 key | ||
* `insecure` boolean, whether to use http or https. defaults to false. | ||
* `bucketLocation` string, one of these: | ||
- "" (default) - US Standard | ||
- "eu-west-1" | ||
- "us-west-1" | ||
- "us-west-2" | ||
- "ap-southeast-1" | ||
- "ap-southeast-2" | ||
- "ap-northeast-1" | ||
- "sa-east-1" | ||
You can find out your bucket location programatically by using this API: | ||
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getBucketLocation-property | ||
returns a string which looks like this: | ||
@@ -164,2 +175,15 @@ | ||
or maybe this if you are not in US Standard: | ||
`https://s3-eu-west-1.amazonaws.com/bucket/key` | ||
### s3.getPublicUrlHttp(bucket, key) | ||
* `bucket` S3 Bucket | ||
* `key` S3 Key | ||
Works for any region, and returns a string which looks like this: | ||
`http://bucket.s3.amazonaws.com/key` | ||
### client.uploadFile(params) | ||
@@ -436,2 +460,7 @@ | ||
### 2.0.0 | ||
* `getPublicUrl` API changed to support bucket regions. Use `getPublicUrlHttp` | ||
if you want an insecure URL. | ||
### 1.3.0 | ||
@@ -438,0 +467,0 @@ |
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
40470
871
501