Skip to content

Commit cf39be3

Browse files
committed
修复 putObject stream 出错
1 parent fa078c1 commit cf39be3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cos-nodejs-sdk-v5",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"description": "cos nodejs sdk v5",
55
"main": "index.js",
66
"scripts": {

sdk/base.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,9 @@ function putObject(params, callback) {
11171117
callback({error: 'lack of param ContentLength'});
11181118
return;
11191119
}
1120-
} else if (Body && typeof Body.pipe === 'string' && util.isBrowser) { // 在浏览器允许传入字符串作为内容 'hello'
1120+
} else if (Body && typeof Body.pipe === 'string') {
1121+
headers['Content-Length'] = Body.length;
1122+
} else if (Body && typeof Body === 'string' && util.isBrowser) { // 在浏览器允许传入字符串作为内容 'hello'
11211123
headers['Content-Length'] = Body.length;
11221124
} else {
11231125
callback({error: 'params body format error, Only allow Buffer, Stream, Blob.'});

0 commit comments

Comments
 (0)