Creating a .wav file in Node.js with fs.writeFile()
<p>I'm attempting to create a <code>.wav</code> file from a blob of data in Node JS, using <code>fs.writeFile()</code>. Firstly, is this even possible?</p>

<p>I'm currently trying with this...</p>

<pre><code>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
        });
    }
});
</code></pre>

<p>The scp of the written file "completes" OK, as I can see the file in the target location, however, it just shows a file size of 0, see below.</p>

<pre><code>-rw-r--r-- 1 root root      0 Jan 21 01:11 1437629575-00220000.wav
</code></pre>

<p>Console output for <code>blob.recording</code> is...</p>

<pre><code>&lt;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 ...&gt;
</code></pre>

<p><code>scp2</code>: <a href="https://github.com/spmjs/node-scp2" rel="nofollow">https://github.com/spmjs/node-scp2</a></p>

<p>I'm thinking I need to encode <code>blob.recording</code> or something. Can anyone point me in the right direction? :-)</p>

<p>Thanks</p>