Skip to content

Commit

Permalink
修复 ContentLength 错误
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Dec 29, 2017
1 parent 846f57c commit 5010b4b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions dist/cos-js-sdk-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -3491,7 +3491,7 @@ var initTask = function (cos) {
var id = util.uuid();
params.TaskReady && params.TaskReady(id);

var size = 0;
var size;
if (params.Body && params.Body.size !== undefined) {
size = params.Body.size;
} else if (params.Body && params.Body.length !== undefined) {
Expand All @@ -3500,6 +3500,8 @@ var initTask = function (cos) {
size = params.ContentLength;
}

if (params.ContentLength === undefined) params.ContentLength = size;
size = size || 0;
params.TaskId = id;

var task = {
Expand Down Expand Up @@ -9984,7 +9986,6 @@ function sliceUploadFile(params, callback) {
var SliceSize = params.SliceSize || this.options.ChunkSize;
var AsyncLimit = params.AsyncLimit;
var StorageClass = params.StorageClass || 'Standard';
var SliceCount;
var FileSize;
var self = this;

Expand Down Expand Up @@ -10071,7 +10072,6 @@ function sliceUploadFile(params, callback) {

// 获取上传文件大小
FileSize = Body.size || params.ContentLength;
SliceCount = Math.ceil(FileSize / SliceSize);

if (FileSize === 0) {
params.Body = '';
Expand Down
2 changes: 1 addition & 1 deletion dist/cos-js-sdk-v5.min.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/advance.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function sliceUploadFile(params, callback) {
var SliceSize = params.SliceSize || this.options.ChunkSize;
var AsyncLimit = params.AsyncLimit;
var StorageClass = params.StorageClass || 'Standard';
var SliceCount;
var FileSize;
var self = this;

Expand Down Expand Up @@ -101,7 +100,6 @@ function sliceUploadFile(params, callback) {

// 获取上传文件大小
FileSize = Body.size || params.ContentLength;
SliceCount = Math.ceil(FileSize / SliceSize);

if (FileSize === 0) {
params.Body = '';
Expand Down
4 changes: 3 additions & 1 deletion src/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ var initTask = function (cos) {
var id = util.uuid();
params.TaskReady && params.TaskReady(id);

var size = 0;
var size;
if (params.Body && params.Body.size !== undefined) {
size = params.Body.size;
} else if (params.Body && params.Body.length !== undefined) {
Expand All @@ -123,6 +123,8 @@ var initTask = function (cos) {
size = params.ContentLength;
}

if (params.ContentLength === undefined) params.ContentLength = size;
size = size || 0;
params.TaskId = id;

var task = {
Expand Down

0 comments on commit 5010b4b

Please sign in to comment.