how do I send (put) multiple files using nodejs ssh2-sftp-client?

后端 未结 3 1884
醉话见心
醉话见心 2021-01-17 01:49

If I try more then 10 files I got the warning, but the other files are not uploaded, I cannot upload more than 10 files. What am I doing wrong?

{ node

3条回答
  •  春和景丽
    2021-01-17 02:20

    This worked for me: https://github.com/theophilusx/ssh2-sftp-client/issues/73

    const putFiles = (sftpConfig, fileList) => {
      const sftp = new sftpClient()
      return new Promise(function(resolve, reject) {
        sftp
        .connect(sftpConfig)
        .then(() => {
          return Promise.all(fileList.map(args => {
            return sftp.put.apply(sftp, args)
          }))
        })
        .then(() => sftp.end())
        .then(resolve)
        .catch(reject)
      });
    }
    

提交回复
热议问题