Sftp
我试图从使用节点的服务器获取一堆 2k 文件和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))
}
这成功地获取了数组中的一个文件并正确命名它,除了每个文件实际上每次都下载相同的文件。
谢谢