Skip to content

Commit e8b1b80

Browse files
committed
修改最大分片大小
1 parent 73c3864 commit e8b1b80

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cos-js-sdk-v5",
3-
"version": "0.4.23",
3+
"version": "0.4.24",
44
"description": "cos js sdk v5",
55
"main": "index.js",
66
"scripts": {

src/advance.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ var util = require('./util');
44

55
// 文件分块上传全过程,暴露的分块上传接口
66
function sliceUploadFile(params, callback) {
7+
var self = this;
78
var ep = new EventProxy();
89
var TaskId = params.TaskId;
910
var Bucket = params.Bucket;
1011
var Region = params.Region;
1112
var Key = params.Key;
1213
var Body = params.Body;
13-
var ChunkSize = params.ChunkSize || params.SliceSize || this.options.ChunkSize;
14+
var ChunkSize = params.ChunkSize || params.SliceSize || self.options.ChunkSize;
1415
var AsyncLimit = params.AsyncLimit;
1516
var StorageClass = params.StorageClass || 'Standard';
1617
var ServerSideEncryption = params.ServerSideEncryption;
1718
var FileSize;
18-
var self = this;
1919

2020
var onProgress;
2121
var onHashProgress = params.onHashProgress;
@@ -134,7 +134,7 @@ function sliceUploadFile(params, callback) {
134134
var AutoChunkSize = 1024 * 1024;
135135
for (var i = 0; i < SIZE.length; i++) {
136136
AutoChunkSize = SIZE[i] * 1024 * 1024;
137-
if (FileSize / AutoChunkSize <= 1024) break;
137+
if (FileSize / AutoChunkSize <= self.options.MaxPartNumber) break;
138138
}
139139
params.ChunkSize = params.SliceSize = ChunkSize = Math.max(ChunkSize, AutoChunkSize);
140140
})();
@@ -1033,7 +1033,7 @@ function sliceCopyFile(params, callback) {
10331033
var AutoChunkSize = 1024 * 1024;
10341034
for (var i = 0; i < SIZE.length; i++) {
10351035
AutoChunkSize = SIZE[i] * 1024 * 1024;
1036-
if (FileSize / AutoChunkSize <= 1024) break;
1036+
if (FileSize / AutoChunkSize <= self.options.MaxPartNumber) break;
10371037
}
10381038
params.ChunkSize = ChunkSize = Math.max(ChunkSize, AutoChunkSize);
10391039

src/cos.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ var defaultOptions = {
1414
ChunkParallelLimit: 3,
1515
ChunkRetryTimes: 3,
1616
ChunkSize: 1024 * 1024,
17+
ChunkMaxCount: 10000,
1718
SliceSize: 1024 * 1024,
1819
CopyChunkParallelLimit: 20,
1920
CopyChunkSize: 1024 * 1024 * 10,
2021
CopySliceSize: 1024 * 1024 * 10,
22+
MaxPartNumber: 10000,
2123
ProgressInterval: 1000,
2224
UploadQueueSize: 10000,
2325
Domain: '',
@@ -41,6 +43,7 @@ var COS = function (options) {
4143
this.options.CopyChunkParallelLimit = Math.max(1, this.options.CopyChunkParallelLimit);
4244
this.options.CopyChunkSize = Math.max(1024 * 1024, this.options.CopyChunkSize);
4345
this.options.CopySliceSize = Math.max(0, this.options.CopySliceSize);
46+
this.options.MaxPartNumber = Math.max(1024, Math.min(10000, this.options.MaxPartNumber));
4447
if (this.options.AppId) {
4548
console.warn('warning: AppId has been deprecated, Please put it at the end of parameter Bucket(E.g: "test-1250000000").');
4649
}
@@ -52,6 +55,6 @@ base.init(COS, task);
5255
advance.init(COS, task);
5356

5457
COS.getAuthorization = util.getAuth;
55-
COS.version = '0.4.23';
58+
COS.version = '0.4.24';
5659

5760
module.exports = COS;

0 commit comments

Comments
 (0)