Wednesday, 10 May 2017

How to write a audio file contend as '.wav' format

When I sending the following request ,

var request = require('request');
var fs = require("fs");    
var headers = {
'Authorization': 'Bearer cEet0ordwd4VsUHi9jnbQuWIYSGP65HEbGtGznHQ4XOaOwaTDQqwLT0bI24oFKLtMvspYvPgi4qR3Bv1oMQp+Wak2x7TRSxsL/oqQN1kIzaWVcGTk9aK4ICxU6qK4tM0KHoAkjA1ahEJSswdB04t89/1O/w1cDnyilFU='

};

var options = {
url: 'https://api.line.me/v2/bot/message/6000684214622/content',
headers: headers
};
var r=request(options );
r.pipe(fs.createWriteStream('./m10.wav' ));

Now the file I can open with a music player. But when I writing the body of the request like,

request(options,function (err,res,body){
var p=body;
p.pipe(fs.createWriteStream('./m10.wav' ));
})

I can't open the file. It shows error. How can I write this file and When I checking the type of both responce first one is an object type and second once is a string type.



via Developer

No comments:

Post a Comment