node-red File read good save

File node is a node file operations

Save file file

 

Drag inject file node into a node (writes msg.payload to a file), and debug node to the canvas, and the connection

Set file nodes in file paths

  • windows If you do not set the path, it will be saved in C: \ Users \ Administrator
  • docker container stored in the root directory

 

Here I select the file name into the data directory, because when I started docker container to / data directory is mounted to the host, and convenient to view files

There are three acts, appended to the file replication file deleted file

Create a directory on the check, or if the directory and the file does not exist, you need to manually create

example:

[{"id":"898828bc.89b418","type":"inject","z":"6c70a17b.e110f","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":290,"y":300,"wires":[["1e951d4f.b4d6a3"]]},{"id":"1e951d4f.b4d6a3","type":"file","z":"6c70a17b.e110f","name":"save","filename":"/data/testtimestamp.txt","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":450,"y":300,"wires":[["c27669f0.bef7e8"]]},{"id":"c27669f0.bef7e8","type":"debug","z":"6c70a17b.e110f","name":"","active":tosidebar",true":true,"console":false,"tostatus":false,"complete":"false","x":610,"y":300,"wires":[]}]

Read the file

Read and save files similar

 

Guess you like

Origin www.cnblogs.com/zhzhlong/p/11505507.html