Skip to content

Commit

Permalink
增加 Location 返回值
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Apr 15, 2021
1 parent 4ca7188 commit 6a57ed0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ function putObject() {
},
Headers: {
// 万象持久化接口,上传时持久化
'Pic-Operations': '{"is_pic_info": 1, "rules": [{"fileid": "test.jpg", "rule": "imageMogr2/thumbnail/!50p"}]}'
// 'Pic-Operations': '{"is_pic_info": 1, "rules": [{"fileid": "test.jpg", "rule": "imageMogr2/thumbnail/!50p"}]}'
},
}, function (err, data) {
logger.log(err || data);
Expand Down
13 changes: 12 additions & 1 deletion dist/cos-js-sdk-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -2221,7 +2221,7 @@ base.init(COS, task);
advance.init(COS, task);

COS.getAuthorization = util.getAuth;
COS.version = '1.2.8';
COS.version = '1.2.9';

module.exports = COS;

Expand Down Expand Up @@ -6985,6 +6985,7 @@ function optionsObject(params, callback) {
function putObjectCopy(params, callback) {

// 特殊处理 Cache-Control
var self = this;
var headers = params.Headers;
if (!headers['Cache-Control'] && !headers['cache-control']) headers['Cache-Control'] = '';

Expand Down Expand Up @@ -7020,7 +7021,17 @@ function putObjectCopy(params, callback) {
}, function (err, data) {
if (err) return callback(err);
var result = util.clone(data.CopyObjectResult || {});
var url = getUrl({
ForcePathStyle: self.options.ForcePathStyle,
protocol: self.options.Protocol,
domain: self.options.Domain,
bucket: params.Bucket,
region: params.Region,
object: params.Key,
isLocation: true
});
util.extend(result, {
Location: url,
statusCode: data.statusCode,
headers: data.headers
});
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": "1.2.8",
"version": "1.2.9",
"description": "JavaScript SDK for [腾讯云对象存储](https://cloud.tencent.com/product/cos)",
"main": "index.js",
"types": "types",
Expand Down
11 changes: 11 additions & 0 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,7 @@ function optionsObject(params, callback) {
function putObjectCopy(params, callback) {

// 特殊处理 Cache-Control
var self = this;
var headers = params.Headers;
if (!headers['Cache-Control'] && !headers['cache-control']) headers['Cache-Control'] = '';

Expand Down Expand Up @@ -2216,7 +2217,17 @@ function putObjectCopy(params, callback) {
}, function (err, data) {
if (err) return callback(err);
var result = util.clone(data.CopyObjectResult || {});
var url = getUrl({
ForcePathStyle: self.options.ForcePathStyle,
protocol: self.options.Protocol,
domain: self.options.Domain,
bucket: params.Bucket,
region: params.Region,
object: params.Key,
isLocation: true,
});
util.extend(result, {
Location: url,
statusCode: data.statusCode,
headers: data.headers,
});
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 = '1.2.8';
COS.version = '1.2.9';

module.exports = COS;

0 comments on commit 6a57ed0

Please sign in to comment.