节点红色Dropbox节点

时间:2020-10-28 00:04:50

标签: dropbox-api node-red

我正在使用node-red-node-dropbox并进行以下工作:

  1. 使用“文件访问”检查文件是否存在,如果存在,则将其上传。
  2. 上载文件后,会得到通知,说明发生了更改,并获取名称和路径,并删除本地文件(如果存在)。 以下是我用于调试的测试低点。 enter image description here

结果: 该文件将被上载到目录(如果存在)。然后被删除。所有工作均按计划进行。 问题是当我转到放箱中的文件时,文件只有几个字节,而不是预期的KB或有时MB。 我对类似问题进行了一些研究,发现了以下内容: Laravel Dropbox API v2 - Empty File on Upload

现在我要说的是,我不是程序员。我正在做一个家庭项目,并试图将timelapse GIF从本地Rpi移到保管箱文件夹。

任何帮助都非常感谢。如果有更新,破解,解决方法,我将采取一切措施。

这是我的测试流程:

[{"id":"4fd3d436.eb8fcc","type":"tab","label":"DropBox","disabled":false,"info":""},{"id":"8e054ce8.884b","type":"function","z":"4fd3d436.eb8fcc","name":"name gif","func":"msg.path = \"/home/pi/.node-red/static/gif/old/\";\n\nmsg.filename = \"img20201027_144920.gif\";\n\nmsg.payload = msg.path + msg.filename\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":180,"wires":[["15144f44.cf7dc1"]]},{"id":"2377960c.da806a","type":"dropbox out","z":"4fd3d436.eb8fcc","dropbox":"","filename":"","localFilename":"","name":"Dropbox","x":1020,"y":180,"wires":[]},{"id":"7a40742d.26a4dc","type":"inject","z":"4fd3d436.eb8fcc","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":180,"wires":[["8e054ce8.884b"]]},{"id":"41e83491.8e6dbc","type":"dropbox in","z":"4fd3d436.eb8fcc","dropbox":"","filepattern":"","name":"","x":220,"y":280,"wires":[["5941e355.c66b9c"]]},{"id":"3003a90.8933658","type":"function","z":"4fd3d436.eb8fcc","name":"gif name","func":"msg.path = \"/home/pi/.node-red/static/gif/old/\";\n\nmsg.filename = msg.file;\n\nmsg.payload = msg.path + msg.filename\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":280,"wires":[["3eeef854.713178"]]},{"id":"5941e355.c66b9c","type":"delay","z":"4fd3d436.eb8fcc","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":400,"y":280,"wires":[["3003a90.8933658"]]},{"id":"9d041a38.f66f48","type":"exec","z":"4fd3d436.eb8fcc","command":"rm ","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":1110,"y":280,"wires":[[],[],[]]},{"id":"77b26b64.855c54","type":"comment","z":"4fd3d436.eb8fcc","name":"Delete local file","info":"Once the file is on dropbox, get the path and file name and delete the local file then","x":240,"y":240,"wires":[]},{"id":"15144f44.cf7dc1","type":"fs-ops-access","z":"4fd3d436.eb8fcc","name":"","path":"path","pathType":"msg","filename":"filename","filenameType":"msg","read":true,"write":true,"throwerror":false,"x":590,"y":180,"wires":[["f0f07147.1b318"],[]]},{"id":"f0f07147.1b318","type":"change","z":"4fd3d436.eb8fcc","name":"","rules":[{"t":"set","p":"filename","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":180,"wires":[["2377960c.da806a"]]},{"id":"22c79cc5.761a64","type":"comment","z":"4fd3d436.eb8fcc","name":"Upload local file","info":"Check if the file exists locally. If it does, then upload it to dropbox","x":240,"y":140,"wires":[]},{"id":"3eeef854.713178","type":"fs-ops-access","z":"4fd3d436.eb8fcc","name":"","path":"path","pathType":"msg","filename":"filename","filenameType":"msg","read":true,"write":true,"throwerror":false,"x":730,"y":280,"wires":[["2ef8b77b.eb0658"],[]]},{"id":"2ef8b77b.eb0658","type":"change","z":"4fd3d436.eb8fcc","name":"","rules":[{"t":"set","p":"filename","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":280,"wires":[["9d041a38.f66f48"]]}]

1 个答案:

答案 0 :(得分:0)

我更改了流程,并添加了readdir以创建目录中所有文件的列表。

Updated Flow

readdir的设置为:

Readdir settings

我基本上指向所有文件所在的目录,并通过将其设置为有效负载的msg.filename属性来一次上传一个文件。这就是Dropbox节点所需要的。现在效果很好。

相关问题