Skip to content

Commit

Permalink
修复 getObjectUrl 多一个 sign=xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Oct 17, 2018
1 parent e8a253a commit ce7f326
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 29 deletions.
33 changes: 19 additions & 14 deletions dist/cos-js-sdk-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -1913,8 +1913,8 @@ var defaultOptions = {
ServiceDomain: '',
Protocol: '',
CompatibilityMode: false,
UploadIdCacheLimit: 50,
ForcePathStyle: false
ForcePathStyle: false,
UploadIdCacheLimit: 50
};

// 对外暴露的类
Expand All @@ -1938,7 +1938,7 @@ util.extend(COS.prototype, base);
util.extend(COS.prototype, advance);

COS.getAuthorization = util.getAuth;
COS.version = '0.4.18';
COS.version = '0.4.19';

module.exports = COS;

Expand Down Expand Up @@ -3802,14 +3802,18 @@ var initTask = function (cos) {
onProgress && onProgress(info);
emitListUpdate();
};
queue.push(task);
if (queue.length > cos.options.UploadQueueSize) {
queue.splice(0, queue.length - cos.options.UploadQueueSize);
}
tasks[id] = task;

// 异步获取 filesize
util.getFileSize(api, params, function (err, size) {
// 获取完文件大小再把任务加入队列
tasks[id] = task;
queue.push(task);
if (queue.length > cos.options.UploadQueueSize) {
var delta = queue.length - cos.options.UploadQueueSize;
queue.splice(0, delta);
nextUploadIndex -= delta;
}
// 开始处理上传
if (err) {
callback(err);
return;
Expand Down Expand Up @@ -5530,13 +5534,14 @@ function getObjectUrl(params, callback) {
Expires: params.Expires
}, function (AuthData) {
if (!callback) return;
url += '?sign=' + encodeURIComponent(AuthData.Authorization);
AuthData.XCosSecurityToken && (url += '&x-cos-security-token=' + AuthData.XCosSecurityToken);
AuthData.ClientIP && (url += '&clientIP=' + AuthData.ClientIP);
AuthData.ClientUA && (url += '&clientUA=' + AuthData.ClientUA);
AuthData.Token && (url += '&token=' + AuthData.Token);
var signUrl = url;
signUrl += '?sign=' + encodeURIComponent(AuthData.Authorization);
AuthData.XCosSecurityToken && (signUrl += '&x-cos-security-token=' + AuthData.XCosSecurityToken);
AuthData.ClientIP && (signUrl += '&clientIP=' + AuthData.ClientIP);
AuthData.ClientUA && (signUrl += '&clientUA=' + AuthData.ClientUA);
AuthData.Token && (signUrl += '&token=' + AuthData.Token);
setTimeout(function () {
callback(null, { Url: url });
callback(null, { Url: signUrl });
});
});
if (authorization) {
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.4.18",
"version": "0.4.19",
"description": "cos js sdk v5",
"main": "index.js",
"scripts": {
Expand Down
13 changes: 7 additions & 6 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -1687,13 +1687,14 @@ function getObjectUrl(params, callback) {
Expires: params.Expires,
}, function (AuthData) {
if (!callback) return;
url += '?sign=' + encodeURIComponent(AuthData.Authorization);
AuthData.XCosSecurityToken && (url += '&x-cos-security-token=' + AuthData.XCosSecurityToken);
AuthData.ClientIP && (url += '&clientIP=' + AuthData.ClientIP);
AuthData.ClientUA && (url += '&clientUA=' + AuthData.ClientUA);
AuthData.Token && (url += '&token=' + AuthData.Token);
var signUrl = url;
signUrl += '?sign=' + encodeURIComponent(AuthData.Authorization);
AuthData.XCosSecurityToken && (signUrl += '&x-cos-security-token=' + AuthData.XCosSecurityToken);
AuthData.ClientIP && (signUrl += '&clientIP=' + AuthData.ClientIP);
AuthData.ClientUA && (signUrl += '&clientUA=' + AuthData.ClientUA);
AuthData.Token && (signUrl += '&token=' + AuthData.Token);
setTimeout(function () {
callback(null, {Url: url});
callback(null, {Url: signUrl});
});
});
if (authorization) {
Expand Down
4 changes: 2 additions & 2 deletions src/cos.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ var defaultOptions = {
ServiceDomain: '',
Protocol: '',
CompatibilityMode: false,
UploadIdCacheLimit: 50,
ForcePathStyle: false,
UploadIdCacheLimit: 50,
};

// 对外暴露的类
Expand All @@ -49,6 +49,6 @@ util.extend(COS.prototype, base);
util.extend(COS.prototype, advance);

COS.getAuthorization = util.getAuth;
COS.version = '0.4.18';
COS.version = '0.4.19';

module.exports = COS;
14 changes: 9 additions & 5 deletions src/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,18 @@ var initTask = function (cos) {
onProgress && onProgress(info);
emitListUpdate();
};
queue.push(task);
if (queue.length > cos.options.UploadQueueSize) {
queue.splice(0, queue.length - cos.options.UploadQueueSize);
}
tasks[id] = task;

// 异步获取 filesize
util.getFileSize(api, params, function (err, size) {
// 获取完文件大小再把任务加入队列
tasks[id] = task;
queue.push(task);
if (queue.length > cos.options.UploadQueueSize) {
var delta = queue.length - cos.options.UploadQueueSize;
queue.splice(0, delta);
nextUploadIndex -= delta;
}
// 开始处理上传
if (err) {
callback(err);
return;
Expand Down

0 comments on commit ce7f326

Please sign in to comment.