Skip to content

Commit

Permalink
修复复制中文错误
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Jul 25, 2018
1 parent 0f5271c commit 291cded
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
13 changes: 8 additions & 5 deletions dist/cos-js-sdk-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,8 @@ var defaultOptions = {
ServiceDomain: '',
Protocol: '',
IgnoreRegionFormat: false,
UploadIdCacheLimit: 50
UploadIdCacheLimit: 50,
CopySliceSize: 1024 * 1024 * 1024 * 50
};

// 对外暴露的类
Expand All @@ -1904,6 +1905,7 @@ var COS = function (options) {
this.options.ChunkParallelLimit = Math.max(1, this.options.ChunkParallelLimit);
this.options.ChunkRetryTimes = Math.max(0, this.options.ChunkRetryTimes);
this.options.ChunkSize = Math.max(1024 * 1024, this.options.ChunkSize);
this.options.CopySliceSize = Math.max(0, this.options.CopySliceSize);
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 @@ -1915,7 +1917,7 @@ util.extend(COS.prototype, base);
util.extend(COS.prototype, advance);

COS.getAuthorization = util.getAuth;
COS.version = '0.4.9';
COS.version = '0.4.10';

module.exports = COS;

Expand Down Expand Up @@ -11178,8 +11180,9 @@ function sliceCopyFile(params, callback) {

var SourceBucket = m[1];
var SourceRegion = m[2];
var SourceKey = m[3];
var SliceSize = Math.min(params.SliceSize, 5 * 1024 * 1024 * 1024);
var SourceKey = decodeURIComponent(m[3]);
var CopySliceSize = params.SliceSize === undefined ? self.options.CopySliceSize : params.SliceSize;
CopySliceSize = Math.max(0, Math.min(params.SliceSize, 5 * 1024 * 1024 * 1024));

var ChunkSize = params.ChunkSize || this.options.ChunkSize;

Expand Down Expand Up @@ -11312,7 +11315,7 @@ function sliceCopyFile(params, callback) {
}

// 开始上传
if (FileSize <= SliceSize) {
if (FileSize <= CopySliceSize) {
self.putObjectCopy(params, callback);
} else {
ep.emit('get_file_size_finish');
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.9",
"version": "0.4.10",
"description": "cos js sdk v5",
"main": "index.js",
"scripts": {
Expand Down
7 changes: 4 additions & 3 deletions src/advance.js
Original file line number Diff line number Diff line change
Expand Up @@ -950,8 +950,9 @@ function sliceCopyFile(params, callback) {

var SourceBucket = m[1];
var SourceRegion = m[2];
var SourceKey = m[3];
var SliceSize = Math.min(params.SliceSize, 5 * 1024 * 1024 * 1024);
var SourceKey = decodeURIComponent(m[3]);
var CopySliceSize = params.SliceSize === undefined ? self.options.CopySliceSize : params.SliceSize;
CopySliceSize = Math.max(0, Math.min(params.SliceSize, 5 * 1024 * 1024 * 1024));

var ChunkSize = params.ChunkSize || this.options.ChunkSize;

Expand Down Expand Up @@ -1084,7 +1085,7 @@ function sliceCopyFile(params, callback) {
}

// 开始上传
if (FileSize <= SliceSize) {
if (FileSize <= CopySliceSize) {
self.putObjectCopy(params, callback);
} else {
ep.emit('get_file_size_finish');
Expand Down
4 changes: 3 additions & 1 deletion src/cos.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var defaultOptions = {
Protocol: '',
IgnoreRegionFormat: false,
UploadIdCacheLimit: 50,
CopySliceSize: 1024 * 1024 * 1024 * 50,
};

// 对外暴露的类
Expand All @@ -31,6 +32,7 @@ var COS = function (options) {
this.options.ChunkParallelLimit = Math.max(1, this.options.ChunkParallelLimit);
this.options.ChunkRetryTimes = Math.max(0, this.options.ChunkRetryTimes);
this.options.ChunkSize = Math.max(1024 * 1024, this.options.ChunkSize);
this.options.CopySliceSize = Math.max(0, this.options.CopySliceSize);
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 @@ -42,6 +44,6 @@ util.extend(COS.prototype, base);
util.extend(COS.prototype, advance);

COS.getAuthorization = util.getAuth;
COS.version = '0.4.9';
COS.version = '0.4.10';

module.exports = COS;

0 comments on commit 291cded

Please sign in to comment.