Im trying to get a bunch 2k files from a Sftp
server using node and ssh2-sftp-client
.
ftp.connect({
host: '...',
port: '...',
username: '...',
password: '...',
readyTimeout: ...
}).then(() => {
return ftp.list('/Stmts/')
}) .then((data) => {
let filesToTransfer = [];
//only get files I dont already have
for (let i = data.length-10; i < data.length; i++) {
if (!blobs.includes(data[i].name)) {
filesToTransfer.push(data[i].name)
}
}
// Get the files in the filesToTransfer Array
for (const file of filesToTransfer){
ftp.fastGet('/Stmts/' + file,
path.join(__dirname, '../Files/' + file))
}
This successfully Gets a file in the array and names it correctly except that every file actually the same file downloaded every time.
Thanks