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:
parent
00a9542edf
commit
78edf89e52
@ -30,9 +30,13 @@ module.exports = function(RED) {
|
|||||||
node.warn('No filename specified');
|
node.warn('No filename specified');
|
||||||
} else if (typeof msg.payload != "undefined") {
|
} else if (typeof msg.payload != "undefined") {
|
||||||
var data = msg.payload;
|
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 (typeof data == "boolean") { data = data.toString(); }
|
||||||
if (this.appendNewline) { data += "\n"; }
|
if ((this.appendNewline)&&(!Buffer.isBuffer(data))) { data += "\n"; }
|
||||||
if (msg.hasOwnProperty('delete')) {
|
if (msg.hasOwnProperty('delete')) {
|
||||||
fs.unlink(filename, function (err) {
|
fs.unlink(filename, function (err) {
|
||||||
if (err) { node.warn('Failed to delete file : '+err); }
|
if (err) { node.warn('Failed to delete file : '+err); }
|
||||||
|
Loading…
Reference in New Issue
Block a user