Reading from a file using a file in node

You can read from a file and inject its content into a flow.

read_manual

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

  1. Open Node-RED.
  2. Add a file in node from the storage category to the workspace.
  3. Double-click the file in node to open the Edit file in node dialogue.
  4. In the Filename text box, specify the path to the file you want to read from (e. g. /home/admin/user).
  5. 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.

  6. In the Output drop-down list, select how you want to output the file content.
  7. a single utf8 string: the entire content of the file is output in a single UTF8-encoded string (for text files only)
  8. a msg per line: each line of the file is output in a separate message (for text files only)
  9. a single Buffer object: the entire content of the file is output in a buffer object
  10. a stream of Buffers: the content of the file is split into 64-kb chunks, which are output in seperate messages
  11. If you want the file in node to send an error message in case of an error, enable the Send message on error (legacy mode) check box.
  12. Click Done to apply your changes.
  13. Connect the input of the file in node to the node which triggers the reading operation.
  14. Connect the output of the file in node to the node you want to inject the file content into.

Catching errors using a catch node