Writing to a file using a file node

You can append data to a file, overwrite a file or delete a file.

read_manual

When using the IoT-Gateway, please also observe the manual Controllers u-control.

  1. Open Node-RED.
  2. Add a file node from the storage category to the workspace.
  3. Double-click the file node to open the Edit file node dialogue.
  4. In the Filename text box, specify the file you want to write to (e. g. /home/admin/user).
  5. ATTENTION

    attention

    Writing to the flash memory of the device degrades the memory. Do not write to the flash memory too often.

  6. notice

    External storage devices are accessible at the file path /run/media/sdxn/, where x is the device letter and n is the device specific partition number (e. g. /run/media/sda1 for the first USB flash drive). If there is only one partition, n is missing.

  7. In the Action drop-down list, select the writing operation. Choose from:
  8. append to file: The payload of the received message is appended to the end of the file (useful for logging).
  9. overwrite file: The data in the file is overwritten with the payload of the received message (useful for binary data e. g. images)
  10. delete file: The file is deleted whenever the node receives a message
  11. If you want to add a newline character after each message, enable the check box Add newline (\n) to each payload?.
  12. If you want to write to a directory that does not yet exist, enable the check box Create directory if it doesn't exist?.
  13. notice

    The /home/admin/user directory on the flash memory does not yet exist in the delivery state of the device.

  14. Click Done to apply your changes.
  15. Connect the input of the file node to the node whose messages trigger the writing operation.