'ssh2-sftp-client uploading first file just fine, but rest of the files with 0 bytes

At node, Im using ssh2-sftp-client and uploading several files which names are in an array.

The first file is uploading perfect, but the rest of the files are uploaded with 0 byte.

Here is my code:

let Client = require('ssh2-sftp-client');
let sftp = new Client();

await sftp.connect({
    host: 'ftp.somedomain.net',
    port: '22',
    username: 'myftpusername',
    password: 'myftppassword',
    "algorithms": {
        "kex": [
            "diffie-hellman-group14-sha1", "diffie-hellman-group-exchange-sha1"
        ]
    }
}).then(() => {
    for (let file of ftpFiles) {
        sftp.fastPut(file.local, file.remote)
    }

}).then(data => {

}).catch(err => {
    console.log(err)
});
sftp.close;

Also, Im not getting any error at the console.

If I upload only one file, it works fine. The problem is with multiple files.

Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source