How to write a file from an ArrayBuffer in JS

Just wanted to add that in newer Meteor you could avoid some callback hell with async/await. Await will also throw and push the error up to client

Meteor.methods({
  uploadFileData: async function(file_id, chunk) {
    var path = 'somepath/' + file_id; // be careful with this, make sure to sanitize file_id
    await fs.appendFile(path, new Buffer(chunk));
    return chunk.length;
  }
});

Saving the file was as easy as creating a new Buffer with the Uint8Array object :

// chunk is the Uint8Array object
fs.appendFile(path, Buffer.from(chunk), function (err) {
    if (err) {
      fut.throw(err);
    } else {
      fut.return(chunk.length);
    }
});

Building on Karl.S answer, this worked for me, outside of any framework:

fs.appendFileSync(outfile, Buffer.from(arrayBuffer));