mscdex / node-ftp

An FTP client module for node.js
MIT License
1.13k stars 243 forks source link

before fs.writeFileSync(),Put function fails (callback isn't called) 。 #254

Closed rzp1 closed 5 years ago

rzp1 commented 5 years ago
  //将文件上传到ftp目标地址
  async function put(currentFile, targetFilePath) {
    const rs = fs.createReadStream(currentFile);
    const fileName = path.basename(targetFilePath);
    return new Promise((resolve, reject) => {
      client.put(rs, fileName, (err) => {
        resolve({ err: err });
        client.end()
      })
    });
  }
  await readyFtp()
  await fs.writeFileSync('./config.json', JSON.stringify(ctx.request.body))
  await put('config.json', 'config.json')

put callback is not work

rzp1 commented 5 years ago

add setTimeout