Comparing version 2.6.1 to 2.7.0
2.7.0 / 2015-09-22 | ||
================== | ||
* feat: support cname and object url | ||
2.6.1 / 2015-09-09 | ||
@@ -3,0 +8,0 @@ ================== |
/**! | ||
* ali-oss - lib/bucket.js | ||
* | ||
* Copyright(c) ali-sdk and other contributors. | ||
@@ -5,0 +3,0 @@ * MIT Licensed |
/**! | ||
* ali-oss - lib/client.js | ||
* | ||
* Copyright(c) ali-sdk and other contributors. | ||
@@ -52,3 +50,5 @@ * MIT Licensed | ||
timeout: '60s', | ||
bucket: null | ||
bucket: null, | ||
endpoint: null, | ||
cname: null, | ||
}; | ||
@@ -58,2 +58,8 @@ | ||
copy(options).and(DEFAULT_OPTIONS).to(this.options); | ||
if (this.options.cname) { | ||
// make sure cname has protocol | ||
if (!/^https?:\/\//.test(this.options.cname)) { | ||
this.options.cname = 'http://' + this.options.cname; | ||
} | ||
} | ||
// support endpoint, alias to host | ||
@@ -219,3 +225,3 @@ this.options.host = this.options.endpoint || this.options.host; | ||
}; | ||
} | ||
}; | ||
@@ -222,0 +228,0 @@ /** |
/**! | ||
* ali-oss - lib/image.js | ||
* | ||
* Copyright(c) ali-sdk and other contributors. | ||
@@ -5,0 +3,0 @@ * MIT Licensed |
/**! | ||
* ali-oss - lib/object.js | ||
* | ||
* Copyright(c) ali-sdk and other contributors. | ||
@@ -59,2 +57,3 @@ * MIT Licensed | ||
name: name, | ||
url: this._objectUrl(name), | ||
res: result.res, | ||
@@ -80,2 +79,3 @@ }; | ||
name: name, | ||
url: this._objectUrl(name), | ||
res: result.res, | ||
@@ -270,5 +270,5 @@ }; | ||
var result = yield* this.request(params); | ||
var result = yield this.request(params); | ||
var objects = result.data.Contents; | ||
var that = this; | ||
if (objects) { | ||
@@ -281,2 +281,3 @@ if (!Array.isArray(objects)) { | ||
name: obj.Key, | ||
url: that._objectUrl(obj.Key), | ||
lastModified: obj.LastModified, | ||
@@ -330,6 +331,10 @@ etag: obj.ETag, | ||
var url = 'http://'; | ||
url += customHost | ||
? customHost + '/' + this._escape(name) | ||
: options.host + this._escape(authResource); | ||
var url; | ||
if (customHost) { | ||
// TODO: need to remove `customHost` support in next major version | ||
// use options.cname instead | ||
url = 'http://' + customHost + '/' + this._escape(name); | ||
} else { | ||
url = this._objectUrl(name); | ||
} | ||
@@ -340,2 +345,12 @@ return url + '?OSSAccessKeyId=' + encodeURIComponent(options.accessKeyId) + | ||
proto._objectUrl = function (name) { | ||
var resourcePath = this._escape('/' + name); | ||
if (this.options.cname) { | ||
return this.options.cname + resourcePath; | ||
} else { | ||
// default url | ||
return 'http://' + this.options.bucket + '.' + this.options.host + resourcePath; | ||
} | ||
}; | ||
/** | ||
@@ -342,0 +357,0 @@ * get content from string(file path), buffer(file content), stream(file stream) |
{ | ||
"name": "ali-oss", | ||
"version": "2.6.1", | ||
"version": "2.7.0", | ||
"description": "aliyun oss(open storage service) node client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -734,2 +734,3 @@ ali-oss | ||
name: 'ossdemo/buffer', | ||
url: 'http://demo.oss-cn-hangzhou.aliyuncs.com/ossdemo/buffer', | ||
res: { | ||
@@ -760,2 +761,3 @@ status: 200, | ||
name: 'ossdemo/readstream.txt', | ||
url: 'http://demo.oss-cn-hangzhou.aliyuncs.com/ossdemo/readstream.txt', | ||
res: { | ||
@@ -818,2 +820,3 @@ status: 200, | ||
name: 'ossdemo/readstream.txt', | ||
url: 'http://demo.oss-cn-hangzhou.aliyuncs.com/ossdemo/readstream.txt', | ||
res: { | ||
@@ -820,0 +823,0 @@ status: 200, |
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
91889
1137
1721