Skip to content

Commit 1ee6941

Browse files
committed
Merge pull request #90 from qiniu/develop
Bug fix: check buffer
2 parents 9d2e434 + 7f23d3c commit 1ee6941

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## CHANGE LOG
22

3+
### v6.1.1
4+
5+
2013-12-5 issue [#90](https://github.com/qiniu/nodejs-sdk/pull/90)
6+
7+
- 创建buffer前检测
8+
9+
310
### v6.1.0
411

512
2013-10-08 issues [#81](https://github.com/qiniu/nodejs-sdk/pull/81)

qiniu/io.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ function PutExtra(params, mimeType, crc32, checkCrc) {
2727
function PutRet(hash, key) {
2828
this.hash = hash || null;
2929
this.key = key || null;
30-
}
30+
}
3131

32-
// onret: callback function instead of ret
32+
// onret: callback function instead of ret
3333
function put(uptoken, key, body, extra, onret) {
3434
if(!extra) {
3535
extra = new PutExtra();
@@ -59,8 +59,8 @@ function getMultipart(uptoken, key, body, extra) {
5959
if(key != exports.UNDEFINED_KEY) {
6060
form.field('key', key);
6161
}
62-
63-
form.buffer('file', new Buffer(body), key, extra.mimeType);
62+
var buf = Buffer.isBuffer(body) ? body : new Buffer(body);
63+
form.buffer('file', buf, key, extra.mimeType);
6464

6565
//extra['checkcrc']
6666
if (extra.checkCrc == 1) {
@@ -100,4 +100,3 @@ function putFile(uptoken, key, loadFile, extra, onret) {
100100
function putFileWithoutKey(uptoken, loadFile, extra, onret) {
101101
putFile(uptoken, null, loadFile, extra, onret);
102102
}
103-

0 commit comments

Comments
 (0)