节点红色Dropbox节点

问题描述

我正在使用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","dropBox":"","filename":"","localFilename":"","name":"DropBox","x":1020,"wires":[]},{"id":"7a40742d.26a4dc","type":"inject","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"wires":[["8e054ce8.884b"]]},{"id":"41e83491.8e6dbc","type":"dropBox in","filepattern":"","x":220,"y":280,"wires":[["5941e355.c66b9c"]]},{"id":"3003a90.8933658","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;","x":560,"wires":[["3eeef854.713178"]]},{"id":"5941e355.c66b9c","type":"delay","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomunits":"seconds","drop":false,"x":400,"wires":[["3003a90.8933658"]]},{"id":"9d041a38.f66f48","type":"exec","command":"rm ","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"x":1110,"wires":[[],[],[]]},{"id":"77b26b64.855c54","type":"comment","name":"Delete local file","info":"Once the file is on dropBox,get the path and file name and delete the local file then","y":240,{"id":"15144f44.cf7dc1","type":"fs-ops-access","path":"path","pathType":"msg","filename":"filename","filenameType":"msg","read":true,"write":true,"throwerror":false,"x":590,"wires":[["f0f07147.1b318"],{"id":"f0f07147.1b318","type":"change","rules":[{"t":"set","p":"filename","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"wires":[["2377960c.da806a"]]},{"id":"22c79cc5.761a64","name":"Upload local file","info":"Check if the file exists locally. If it does,then upload it to dropBox","y":140,{"id":"3eeef854.713178","x":730,"wires":[["2ef8b77b.eb0658"],{"id":"2ef8b77b.eb0658","x":930,"wires":[["9d041a38.f66f48"]]}]

解决方法

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

Updated Flow

readdir的设置为:

Readdir settings

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