Advanced-ftp does not work when feeding filename and localFilename

Hi,

I have a flow where the advanced-ftp node works when I put in the filename and localFilename in the node.

however, I leave them blank and feed the filename and localFilename using a function node, it doesn't seem to work. I could be missing something very simple here but here is my function

var local = msg.payload; var remote = "/site/invoices/"+msg.payload; var localn = "C:\\PosPlus\\Invoices\\Working\\"+local; msg.filename = remote; msg.localFilename = localn; return msg;

Error: The filename, directory name, or volume label syntax is incorrect.

But when I copy the value of the msg.filename and msg.localFilename to the node itself it works.

What am I doing wrong?

Thank you in advance, Let me know if you need more information.

Feed that into a debug node set to show Complete Message and check everything looks right. I suggest you use forward slashes rather that backslash, then you don't have to worry about escaping them. Forward slashes work fine in Windows.

{"payload":"","topic":"","filename":"/site/invoices/Produce_Invoice_003_03192021_125956.csv\r","parts":{"index":2,"ch":"\n","type":"string","id":"d2887f53.ef9f"},"_msgid":"e0ff6a24.f0f548","localFilename":"C:/PosPlus/Invoices/Working/Produce_Invoice_003_03192021_125956.csv\r"}

That's the complete message object. I see the /r in there do you think that's the problem?

Quite possibly. If you put
msg.payload = msg.payload.trim()
at the start then I think that will remove those. Check in the debug node to see. Or do that wherever you create msg.payload earlier in the flow.

Whenever you have a problem with a node the first thing to do is to look at what you are sending it and make sure it looks right.

That did it!! Thank you Colin!!

Will pay closer attention next time. :slight_smile: