node.jsfile-uploadpromisessh2-sftp

promise-sftp hangs after 'put'


I am working on a NodeJS component uploading a file to an SFTP server using promise-sftp version 0.11.3. I am basically doing these steps:

const PromiseFtp = require('promise-sftp');
const ftp = new PromiseFtp();
await ftp.connect(...);
await ftp.put(imageBuf, './subdir/fileName');
await ftp.end();

I ensured that all the steps are working correctly up to put. imageBuf is a Buffer object storing binary image data. I have these effects which I don't understand:

I already tried to put a ftp.stat call right after the put. Doing so results in not returning from the stat call anymore. I have another function calling ftp.unlink instead of put which is working correctly. That's why I guess that the put call is the culprit.

Am I doing something wrong here? Is there any way I can debug my code to see what's happening/what goes wrong?


Solution

  • After some further investigation, I realized that the uploaded image was also cut-off when passing a filename to put. I tried to output debug information (using the debug argument passed to the connect call), but I could not see any useful hints for resolving my issue.

    Reading the documentation of the promise-sftp package, I realized that the last update as well the the latest issues are over 3 years old with the documentation not being updated since version 0.9.0. As some issues are tagged with "help wanted" my guess is, that the package is not being maintained actively.

    So I finally switched to the package ssh2-sftp-client, which is quite up to date. I did not even have to change the code (only the require argument, obviously) and the upload is now working flawlessly.