1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Allow File node to write out buffers of binary data

This commit is contained in:
Dave C-J 2014-07-29 08:57:12 +01:00
parent 00a9542edf
commit 78edf89e52

View File

@ -30,9 +30,13 @@ module.exports = function(RED) {
node.warn('No filename specified');
} else if (typeof msg.payload != "undefined") {
var data = msg.payload;
if (typeof data == "object") { data = JSON.stringify(data); }
if (typeof data == "object") {
if (!Buffer.isBuffer(data)) {
data = JSON.stringify(data);
}
}
if (typeof data == "boolean") { data = data.toString(); }
if (this.appendNewline) { data += "\n"; }
if ((this.appendNewline)&&(!Buffer.isBuffer(data))) { data += "\n"; }
if (msg.hasOwnProperty('delete')) {
fs.unlink(filename, function (err) {
if (err) { node.warn('Failed to delete file : '+err); }