Search code examples
sftpnode-red

Node-Red Get File from SFTP


I am using Node-red to connect to SFTP and to get a file. Th Problem is that it returns always this error:

"Error: sftp.realPath: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received type number (1645531908336) 1645531908336"

Note: I did not get this error on "List" and i have tried many SFTP servers. Always the same error

this is the image of my node

enter image description here


Solution

  • 1645531908336 looks like it is the timestamp from a standard msg.payload value from an inject node.

    Assuming this is the node-red-contrib-better-sftp node then it looks like it is badly written and will always take the value of msg.payload and override any configured path and filename in the node config. This is a really bad design and should only use the input message if the value is left blank in the config.

    https://github.com/sublime93/node-red-contrib-better-sftp/blob/10f67d46f3d762b254f7a6f22539ba4c95d6331e/transports/sftp/index.js#L148

    So the quick option for you to test is to remove the msg.payload from the inject node you are testing with.

    You should also raise an issue with the nodes author to fix this behaviour.

    EDIT: There already is an open issue (from mid 2020) https://github.com/sublime93/node-red-contrib-better-sftp/issues/9