Skip to content

Commit

Permalink
修改最大分片大小
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Nov 15, 2018
1 parent 73c3864 commit e8b1b80
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
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.23",
"version": "0.4.24",
"description": "cos js sdk v5",
"main": "index.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions src/advance.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ var util = require('./util');

// 文件分块上传全过程,暴露的分块上传接口
function sliceUploadFile(params, callback) {
var self = this;
var ep = new EventProxy();
var TaskId = params.TaskId;
var Bucket = params.Bucket;
var Region = params.Region;
var Key = params.Key;
var Body = params.Body;
var ChunkSize = params.ChunkSize || params.SliceSize || this.options.ChunkSize;
var ChunkSize = params.ChunkSize || params.SliceSize || self.options.ChunkSize;
var AsyncLimit = params.AsyncLimit;
var StorageClass = params.StorageClass || 'Standard';
var ServerSideEncryption = params.ServerSideEncryption;
var FileSize;
var self = this;

var onProgress;
var onHashProgress = params.onHashProgress;
Expand Down Expand Up @@ -134,7 +134,7 @@ function sliceUploadFile(params, callback) {
var AutoChunkSize = 1024 * 1024;
for (var i = 0; i < SIZE.length; i++) {
AutoChunkSize = SIZE[i] * 1024 * 1024;
if (FileSize / AutoChunkSize <= 1024) break;
if (FileSize / AutoChunkSize <= self.options.MaxPartNumber) break;
}
params.ChunkSize = params.SliceSize = ChunkSize = Math.max(ChunkSize, AutoChunkSize);
})();
Expand Down Expand Up @@ -1033,7 +1033,7 @@ function sliceCopyFile(params, callback) {
var AutoChunkSize = 1024 * 1024;
for (var i = 0; i < SIZE.length; i++) {
AutoChunkSize = SIZE[i] * 1024 * 1024;
if (FileSize / AutoChunkSize <= 1024) break;
if (FileSize / AutoChunkSize <= self.options.MaxPartNumber) break;
}
params.ChunkSize = ChunkSize = Math.max(ChunkSize, AutoChunkSize);

Expand Down
5 changes: 4 additions & 1 deletion src/cos.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ var defaultOptions = {
ChunkParallelLimit: 3,
ChunkRetryTimes: 3,
ChunkSize: 1024 * 1024,
ChunkMaxCount: 10000,
SliceSize: 1024 * 1024,
CopyChunkParallelLimit: 20,
CopyChunkSize: 1024 * 1024 * 10,
CopySliceSize: 1024 * 1024 * 10,
MaxPartNumber: 10000,
ProgressInterval: 1000,
UploadQueueSize: 10000,
Domain: '',
Expand All @@ -41,6 +43,7 @@ var COS = function (options) {
this.options.CopyChunkParallelLimit = Math.max(1, this.options.CopyChunkParallelLimit);
this.options.CopyChunkSize = Math.max(1024 * 1024, this.options.CopyChunkSize);
this.options.CopySliceSize = Math.max(0, this.options.CopySliceSize);
this.options.MaxPartNumber = Math.max(1024, Math.min(10000, this.options.MaxPartNumber));
if (this.options.AppId) {
console.warn('warning: AppId has been deprecated, Please put it at the end of parameter Bucket(E.g: "test-1250000000").');
}
Expand All @@ -52,6 +55,6 @@ base.init(COS, task);
advance.init(COS, task);

COS.getAuthorization = util.getAuth;
COS.version = '0.4.23';
COS.version = '0.4.24';

module.exports = COS;

0 comments on commit e8b1b80

Please sign in to comment.