Skip to content

Commit

Permalink
v0.5.20 优化 putObject 返回 Location
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Sep 11, 2019
1 parent c34bf68 commit b96322e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
13 changes: 8 additions & 5 deletions dist/cos-js-sdk-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,7 @@ base.init(COS, task);
advance.init(COS, task);

COS.getAuthorization = util.getAuth;
COS.version = '0.5.19';
COS.version = '0.5.20';

module.exports = COS;

Expand Down Expand Up @@ -5026,7 +5026,7 @@ function putObject(params, callback) {
return callback(err);
}
onProgress({ loaded: FileSize, total: FileSize }, true);
if (data && data.headers && data.headers['etag']) {
if (data) {
var url = getUrl({
ForcePathStyle: self.options.ForcePathStyle,
protocol: self.options.Protocol,
Expand All @@ -5036,12 +5036,15 @@ function putObject(params, callback) {
object: params.Key
});
url = url.substr(url.indexOf('://') + 3);
return callback(null, {
var result = {
Location: url,
ETag: data.headers['etag'],
statusCode: data.statusCode,
headers: data.headers
});
};
if (data.headers && data.headers.etag) {
result.ETag = data.headers.etag;
}
return callback(null, result);
}
callback(null, data);
});
Expand Down
2 changes: 1 addition & 1 deletion dist/cos-js-sdk-v5.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cos-js-sdk-v5",
"version": "0.5.19",
"version": "0.5.20",
"description": "JavaScript SDK for [腾讯云对象存储](https://cloud.tencent.com/product/cos)",
"main": "index.js",
"scripts": {
Expand Down
11 changes: 7 additions & 4 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ function putObject(params, callback) {
return callback(err);
}
onProgress({loaded: FileSize, total: FileSize}, true);
if (data && data.headers && data.headers['etag']) {
if (data) {
var url = getUrl({
ForcePathStyle: self.options.ForcePathStyle,
protocol: self.options.Protocol,
Expand All @@ -1049,12 +1049,15 @@ function putObject(params, callback) {
object: params.Key,
});
url = url.substr(url.indexOf('://') + 3);
return callback(null, {
var result = {
Location: url,
ETag: data.headers['etag'],
statusCode: data.statusCode,
headers: data.headers,
});
};
if (data.headers && data.headers.etag) {
result.ETag = data.headers.etag;
}
return callback(null, result);
}
callback(null, data);
});
Expand Down
2 changes: 1 addition & 1 deletion src/cos.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ base.init(COS, task);
advance.init(COS, task);

COS.getAuthorization = util.getAuth;
COS.version = '0.5.19';
COS.version = '0.5.20';

module.exports = COS;

0 comments on commit b96322e

Please sign in to comment.