网站建设资讯

NEWS

网站建设资讯

node-redFile读取好保存实例讲解-创新互联

File节点是操作文件的节点

为开化等地区用户提供了全套网页设计制作服务,及开化网站建设行业解决方案。主营业务为做网站、网站制作、开化网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

file文件的保存

node-red File读取好保存实例讲解

拖拽 注入节点inject  file节点(writes msg.payload to a file)和 debug节点到工作区,并连线

设置file节点的文件路径

windows如果不设置路径,会保存在C:\Users\Administratordocker容器保存在根目录下

node-red File读取好保存实例讲解

此处文件名我选择 放到data目录下,因为docker容器启动的时候我把/data目录挂载到宿主机上了,方便查看文件

行为有三种,追加至文件  复写文件  删除文件

勾选上创建目录,否则如果目录和文件不存在,需要手动创建

例子:

[{"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":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":610,"y":300,"wires":[]}]

文章名称:node-redFile读取好保存实例讲解-创新互联
网页链接:http://cdweb.net/article/cojooc.html