diff --git a/nodes/core/storage/50-file.js b/nodes/core/storage/50-file.js index 7fce15e90..d6cc4410d 100644 --- a/nodes/core/storage/50-file.js +++ b/nodes/core/storage/50-file.js @@ -35,21 +35,23 @@ module.exports = function(RED) { }); } else if (typeof msg.payload != "undefined") { var data = msg.payload; - if (typeof data == "object") { + if (typeof data === "object") { if (!Buffer.isBuffer(data)) { data = JSON.stringify(data); } } - if (typeof data == "boolean") { data = data.toString(); } + if (typeof data === "boolean") { data = data.toString(); } if ((this.appendNewline)&&(!Buffer.isBuffer(data))) { data += "\n"; } if (this.overwriteFile) { - fs.writeFile(filename, data, function (err) { + // using "binary" not {encoding:"binary"} to be 0.8 compatible for a while + fs.writeFile(filename, data, "binary", function (err) { if (err) { node.warn('Failed to write to file : '+err); } //console.log('Message written to file',filename); }); } else { - fs.appendFile(filename, data, function (err) { + // using "binary" not {encoding:"binary"} to be 0.8 compatible for a while + fs.appendFile(filename, data, "binary", function (err) { if (err) { node.warn('Failed to append to file : '+err); } //console.log('Message appended to file',filename); });