Skip to content

Commit

Permalink
修复 putObject 传空字符串的报错
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Mar 6, 2018
1 parent 4c8f9ce commit 4dc8ef5
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 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 @@ -612,7 +612,7 @@ util.extend(COS.prototype, base);
util.extend(COS.prototype, advance);

COS.getAuthorization = util.getAuth;
COS.version = '0.3.9';
COS.version = '0.3.10';

module.exports = COS;

Expand Down Expand Up @@ -2547,7 +2547,7 @@ function putObject(params, callback) {
if (util.isBrowser && Body && (Body instanceof global.Blob || Body instanceof global.File)) {
// 在浏览器允许传入 Blob 或者 File 文件内容
headers['Content-Length'] = Body.size;
} else if (util.isBrowser && Body && typeof Body === 'string') {
} else if (util.isBrowser && typeof Body === 'string') {
// 在浏览器允许传入字符串作为内容 'hello'
headers['Content-Length'] = Body.length;
} else if (Body && typeof Body.pipe === 'function') {
Expand Down Expand Up @@ -3318,7 +3318,7 @@ function getUrl(params) {
var region = params.region;
var object = params.object;
var action = params.action;
var protocol = util.isBrowser && location.protocol === 'https:' ? 'https:' : 'http:';
var protocol = util.isBrowser && location.protocol === 'http:' ? 'http:' : 'https:';
if (!domain) {
if (['cn-south', 'cn-south-2', 'cn-north', 'cn-east', 'cn-southwest', 'sg'].indexOf(region) > -1) {
domain = '{{Bucket}}-{{AppId}}.{{Region}}.myqcloud.com';
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.3.9",
"version": "0.3.10",
"description": "cos js sdk v5",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/advance.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function sliceUploadFile(params, callback) {
FileSize: FileSize,
SliceSize: ChunkSize,
AsyncLimit: AsyncLimit,
ServerSideEncryption: ServerSideEncryption,
ServerSideEncryption: ServerSideEncryption,
UploadData: UploadData,
onProgress: onProgress
}, function (err, data) {
Expand Down
4 changes: 2 additions & 2 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ function putObject(params, callback) {

if (util.isBrowser && Body && (Body instanceof global.Blob || Body instanceof global.File)) { // 在浏览器允许传入 Blob 或者 File 文件内容
headers['Content-Length'] = Body.size;
} else if (util.isBrowser && Body && typeof Body === 'string') { // 在浏览器允许传入字符串作为内容 'hello'
} else if (util.isBrowser && typeof Body === 'string') { // 在浏览器允许传入字符串作为内容 'hello'
headers['Content-Length'] = Body.length;
} else if (Body && typeof Body.pipe === 'function') { // fs.createReadStream(filepath)
readStream = Body;
Expand Down Expand Up @@ -1704,7 +1704,7 @@ function getUrl(params) {
var region = params.region;
var object = params.object;
var action = params.action;
var protocol = util.isBrowser && location.protocol === 'https:' ? 'https:' : 'http:';
var protocol = util.isBrowser && location.protocol === 'http:' ? 'http:' : 'https:';
if (!domain) {
if (['cn-south', 'cn-south-2', 'cn-north', 'cn-east', 'cn-southwest', 'sg'].indexOf(region) > -1) {
domain = '{{Bucket}}-{{AppId}}.{{Region}}.myqcloud.com';
Expand Down
2 changes: 1 addition & 1 deletion src/cos.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ util.extend(COS.prototype, base);
util.extend(COS.prototype, advance);

COS.getAuthorization = util.getAuth;
COS.version = '0.3.9';
COS.version = '0.3.10';

module.exports = COS;

0 comments on commit 4dc8ef5

Please sign in to comment.