I am trying to create a .wav file from a data drop in Node JS using fs.writeFile() . First, is this possible?
I'm currently trying with this ...
fs.writeFile(filename + '.wav', blob.recording, function (err) { // On completing writeFile, transfer file via scp var options = {...}; var target_path = "the/path" if (err) return logger.error(err); else{ scp2.scp(options, target_path, function (err) { // scp2 callback: always gets here }); } });
The script of the recorded file โcompletesโ OK, since I can see the file in the target location, however it just shows the file size 0, see below.
-rw-r--r-- 1 root root 0 Jan 21 01:11 1437629575-00220000.wav
The console output for blob.recording is ...
<Buffer 52 49 46 46 4d b9 00 00 57 41 56 45 66 6d 74 20 14 00 00 00 31 00 01 00 40 1f 00 00 59 06 00 00 41 00 00 00 02 00 40 01 66 61 63 74 04 00 00 00 40 8f 03 ...>
scp2 : https://github.com/spmjs/node-scp2
I think I need to code blob.recording or something else. Can someone point me in the right direction ?:-)
thanks
source share