FTP Node not getting the file

Trying to grab the latest image(jpg) from a FTP server and cant quite get the flow to work. Can list and sort by date/time and find the image but get this error. Any advice on what I am missing here?

msg : error
"Error: domain.com/Camera: Not a regular file"

Node is node-red-contrib-ftp (node) - Node-RED

[{"id":"467354e6dd094a5f","type":"tab","label":"FTP","disabled":false,"info":"","env":[]},{"id":"24626896040b533b","type":"inject","z":"467354e6dd094a5f","name":"","props":[{"p":"payload"}],"repeat":"900","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"domain.com/Camera","payloadType":"str","x":170,"y":80,"wires":[["20526ae0a26ae312"]]},{"id":"908688915e0316a5","type":"debug","z":"467354e6dd094a5f","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":520,"y":460,"wires":[]},{"id":"b5b6413096f7a827","type":"function","z":"467354e6dd094a5f","name":"Modification time","func":"msg.payload = msg.payload.filter(f => f.type === '-' && f.name.endsWith('.jpg'));\nmsg.payload.sort((a, b) => b.mtime - a.mtime);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":100,"wires":[["c39a2fefed02e46a"]]},{"id":"c39a2fefed02e46a","type":"function","z":"467354e6dd094a5f","name":"Get lastest JPG","func":"msg.payload = msg.payload[0];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":100,"wires":[["908688915e0316a5","371e4e28593fe0db"]]},{"id":"cb113c4c0235ae0a","type":"ftp in","z":"467354e6dd094a5f","ftp":"e4dabfec9bae8847","operation":"list","filename":"","localFilename":"","name":"List","x":430,"y":240,"wires":[["b5b6413096f7a827","908688915e0316a5"]]},{"id":"20526ae0a26ae312","type":"change","z":"467354e6dd094a5f","name":"pay to filename","rules":[{"t":"move","p":"payload","pt":"msg","to":"filename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":140,"wires":[["cb113c4c0235ae0a"]]},{"id":"92d8024d72c3ec93","type":"ftp in","z":"467354e6dd094a5f","ftp":"e4dabfec9bae8847","operation":"get","filename":"","localFilename":"/media/camera/CamImage.jpg","name":"Get","x":1050,"y":240,"wires":[["908688915e0316a5"]]},{"id":"371e4e28593fe0db","type":"function","z":"467354e6dd094a5f","name":"function 1","func":"msg.payload = \"domain.com/Camera/\" + msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1000,"y":100,"wires":[["92d8024d72c3ec93"]]},{"id":"e4dabfec9bae8847","type":"ftp","host":"0.0.0.0","port":"21","secureOptions":"","user":"FTPuser","connTimeout":"","pasvTimeout":"","keepalive":""}]

I think you cannot specify a folder in the file name. The folder must be specified separately.

Having said that I failed trying to get various FTP nodes to work well, sand changed to using exec nodes and calling the system command directly.

If I explicitly add this it works but I need it to be the last image filename hence can explicitly put the path, if filename is blank assumes it picks up the msg.payload?

image

I have no idea, as I said, I gave up the FTP nodes.

Managed to get this flow to work

[{"id":"467354e6dd094a5f","type":"tab","label":"FTP","disabled":false,"info":"","env":[]},{"id":"693ccb5aebc659fc","type":"inject","z":"467354e6dd094a5f","name":"Get Image every 15 min","props":[{"p":"payload"}],"repeat":"14400","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"domain.com/Camera","payloadType":"str","x":170,"y":60,"wires":[["31ff6b36e0b622f5"]]},{"id":"db3c92f6d1276edb","type":"debug","z":"467354e6dd094a5f","name":"Debug Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1060,"y":120,"wires":[]},{"id":"7a6112c6c872a215","type":"function","z":"467354e6dd094a5f","name":"Filter by modification time","func":"// Extracts the creation time stamp from a file name in the format yymmddHHMMSS.jpg\nfunction getCreationTime(name) {\n    const match = name.match(/(\\d{12})\\.jpg/);\n    if (match) {\n        return parseInt(match[1]);\n    } else {\n        return 0;\n    }\n}\n\n// Sorts an array of file objects by their creation time stamp in descending order\nmsg.payload.sort((a, b) => getCreationTime(b.name) - getCreationTime(a.name));\n\n// Return the sorted array\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":200,"wires":[["f1bb984e6636c890"]]},{"id":"f1bb984e6636c890","type":"function","z":"467354e6dd094a5f","name":"Get lastest JPG","func":"msg.payload = msg.payload[0];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":260,"wires":[["db3c92f6d1276edb","48739aa8b805ab67"]]},{"id":"31ff6b36e0b622f5","type":"change","z":"467354e6dd094a5f","name":"Move Payload to Filename","rules":[{"t":"move","p":"payload","pt":"msg","to":"filename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":60,"wires":[["edb48ac579207041"]]},{"id":"48739aa8b805ab67","type":"function","z":"467354e6dd094a5f","name":"Fn add remote file path + image","func":"msg.filename = \"/domain.com/Camera/\" + msg.payload.name;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":320,"wires":[["db3c92f6d1276edb","d5c53eae596e0b98"]]},{"id":"edb48ac579207041","type":"ftp in","z":"467354e6dd094a5f","ftp":"88b86ecb9b39502e","operation":"list","filename":"","localFilename":"","name":"List","x":430,"y":140,"wires":[["7a6112c6c872a215","db3c92f6d1276edb"]]},{"id":"d5c53eae596e0b98","type":"ftp in","z":"467354e6dd094a5f","ftp":"88b86ecb9b39502e","operation":"get","filename":"","localFilename":"/config/www/camera/CamImage.jpg","name":"Get latest image","x":440,"y":400,"wires":[["db3c92f6d1276edb"]]},{"id":"3bafc7b37597d33a","type":"comment","z":"467354e6dd094a5f","name":"Details and Links","info":"","x":120,"y":400,"wires":[]},{"id":"88b86ecb9b39502e","type":"ftp","host":"00.00.00.00","port":"21","secureOptions":"","user":"FTPuser","connTimeout":"30000","pasvTimeout":"10000","keepalive":"10000"}]

Logs into the remote FTP grabs the latest JPG and stores to local.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.