Not able to write file content into SFTP folder

HI All,

I have installed "node-red-contrib-better-sftp" into my node red and using this am trying to create the file with the content into the SFTP folder.
Issue : i have done the configuration and able to create a file into my specified folder but it is a empty is getting created.
Please suggest/guide me if i am missing anything on this code.



image
image

Here all the files created 0 KB with no content.

Please help me to resolve this problem

Library downloaded from : node-red-contrib-better-sftp (node) - Node-RED.

I think the important point is that if msg.payload.data is a string it will be considered to be a path to a local file, where local means on the machine running the Node-RED backend.

So in this case the node will look for the file ./data/testfile/SAMPLE.txt. That is a relative path which may also be a problem as I can never remember without testing if this ends up being relative to the directory Node-RED was started from or somewhere else.

If you just want to write a string to the file then it needs to be converted to a buffer first.

msg.payload.data = Buffer.from("some string", "utf-8");
1 Like

Thank You very much Hardilib. Your solutions worked for me. Now i am able to write data into the file in SFTP.

1 Like

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