@@ -27,9 +27,9 @@ function PutExtra(params, mimeType, crc32, checkCrc) {
2727function 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
3333function 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) {
100100function putFileWithoutKey ( uptoken , loadFile , extra , onret ) {
101101 putFile ( uptoken , null , loadFile , extra , onret ) ;
102102}
103-
0 commit comments