Skip to content

Commit b77ee1f

Browse files
committed
支持 Timeout 选项
1 parent 87d1b71 commit b77ee1f

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

demo/demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ function deleteBucket() {
439439
console.log(err || data);
440440
});
441441
}
442-
442+
return putObject();
443443
function putObject() {
444444
// 创建测试文件
445445
var filename = '1mb.zip';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cos-nodejs-sdk-v5",
3-
"version": "2.4.15",
3+
"version": "2.4.16",
44
"description": "cos nodejs sdk v5",
55
"main": "index.js",
66
"scripts": {

sdk/base.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,6 +2202,9 @@ function _submitRequest(params, callback) {
22022202
if (this.options.Proxy) {
22032203
opt.proxy = this.options.Proxy;
22042204
}
2205+
if (this.options.Timeout) {
2206+
opt.timeout = this.options.Timeout;
2207+
}
22052208

22062209
self.emit('before-send', opt);
22072210
var sender = REQUEST(opt);

sdk/cos.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var defaultOptions = {
3131
UseRawKey: false,
3232
UploadCheckContentMd5: false,
3333
UploadIdCacheLimit: 500,
34+
Timeout: 0, // 单位毫秒,0 代表不设置超时时间
3435
Proxy: '',
3536
UserAgent: '',
3637
};
@@ -46,6 +47,7 @@ var COS = function (options) {
4647
this.options.CopyChunkSize = Math.max(1024 * 1024, this.options.CopyChunkSize);
4748
this.options.CopySliceSize = Math.max(0, this.options.CopySliceSize);
4849
this.options.MaxPartNumber = Math.max(1024, Math.min(10000, this.options.MaxPartNumber));
50+
this.options.Timeout = Math.max(0, this.options.Timeout);
4951
if (this.options.AppId) {
5052
console.warn('warning: AppId has been deprecated, Please put it at the end of parameter Bucket(E.g: "test-1250000000").');
5153
}

0 commit comments

Comments
 (0)