@@ -27,9 +27,9 @@ function PutExtra(params, mimeType, crc32, checkCrc) {
27
27
function PutRet ( hash , key ) {
28
28
this . hash = hash || null ;
29
29
this . key = key || null ;
30
- }
30
+ }
31
31
32
- // onret: callback function instead of ret
32
+ // onret: callback function instead of ret
33
33
function put ( uptoken , key , body , extra , onret ) {
34
34
if ( ! extra ) {
35
35
extra = new PutExtra ( ) ;
@@ -59,8 +59,8 @@ function getMultipart(uptoken, key, body, extra) {
59
59
if ( key != exports . UNDEFINED_KEY ) {
60
60
form . field ( 'key' , key ) ;
61
61
}
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 ) ;
64
64
65
65
//extra['checkcrc']
66
66
if ( extra . checkCrc == 1 ) {
@@ -100,4 +100,3 @@ function putFile(uptoken, key, loadFile, extra, onret) {
100
100
function putFileWithoutKey ( uptoken , loadFile , extra , onret ) {
101
101
putFile ( uptoken , null , loadFile , extra , onret ) ;
102
102
}
103
-
0 commit comments