Cannot access filename when using node-red-contrib-ftp-server

Hi, I am trying to use the FTP server node but are facing a problem.
My flow is as below:

As can be seem the filename is topic of the message.
But whatever I do to extract the filename and remove the "/" results either on some error or undefined.
If I insert a function node before the debug node I can do:
var imgname = msg.topic;
It works as below:

But if I try to remove the "/" from the filename (using replace or substring) nothing happens, no error, no print but I have to restart node-red for the FTP node to work again.

What Am I doing wrong?

You have not shown what you have tried, so don't know if this has been tried

msg.imgname = msg.topic.substr(1);
return msg;
[{"id":"15c42ff2.e05b68","type":"inject","z":"a3b92cc4.e3cb","name":"","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"/23456 (1).jpg","payload":"[1,2,3,4,5,6,7]","payloadType":"bin","x":220,"y":100,"wires":[["1c362b66.bdde3d"]]},{"id":"1c362b66.bdde3d","type":"function","z":"a3b92cc4.e3cb","name":"","func":"msg.imgname = msg.topic.substr(1);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":120,"wires":[["fc7a6130.f3f4e","87e02340.b97f7"]]},{"id":"fc7a6130.f3f4e","type":"debug","z":"a3b92cc4.e3cb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":510,"y":100,"wires":[]}]
msg.newimgname = msg.imgname.substring(1);
return msg;

Testing your suggestion...

While your at it can we see the debug output of the ftp node?

The FTP node returns the image in payload and filename as topic.
It is working now with your sugestion.

I was first making imgname = msg.payload and then
Somehow imgname was visible at the debug window but when addressed with msg.imgname it somehow, would return undefined.

But when I used msg.imgname = msg.topic.substr(1); as you sugested above it works OK.
Now I can debug msg.imgname and it returns the expected value.

Many thanks.

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