Store the empty msg.payload inside the file

hello everyone, I have a problem I have to store files with the name that is entered in a textbox, and I succeeded the only problem I have is that all the msg.payload is saved inside the file when in actually I need it to be empty
0



3

let a = "/path/to/file/";
msg.file = a + msg.payload.file;
msg.payload = "";
return msg;

Then in the file node use msg.file, and uncheck add a newline to each payload.

1 Like

Perfect works very well thanks.
another question if i can how do i make the variable
global "msg.file" so that it can also be used in another flow or even on blocks that are not directly connected to each other

You can global.set in the function before returning message.
This is explained in docs
https://nodered.org/docs/user-guide/context
https://nodered.org/docs/user-guide/writing-functions#storing-data

Or you can use a change node to set global.file to msg.file

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.