使用nodejs将文件从一个目录移动到FTP服务器上的另一个目录的模块

发布于 2025-01-19 04:42:49 字数 422 浏览 3 评论 0原文

我已经尝试了所有模块,如node-ftp、ftp-client、ftp-srv 我找到了 basic-ftp,但它允许我们下载文件,然后将文件上传到目录,但我想将所有文件从一个目录移动到另一个目录,而不是下载然后移动它。 我已成功使用 ftp 列出该文件,阅读后我想将其移动到新目录

return new Promise((resolve, reject) => {
    client.list(path, function (err, list) {
      let data = [];
      if (err) {
        reject(error);
      }
      data = (list && list.data) || [];
      return resolve(list);
    });
  });

I have tried all the modules like node-ftp, ftp-client, ftp-srv
i found basic-ftp but it allow us to download the file and then upload the file to a directory but i want to move all the files from one directory to another instead of downloading and then moving it.
I have successfully list the file using ftp and after reading i want to move it to a new directory

return new Promise((resolve, reject) => {
    client.list(path, function (err, list) {
      let data = [];
      if (err) {
        reject(error);
      }
      data = (list && list.data) || [];
      return resolve(list);
    });
  });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

跨年 2025-01-26 04:42:49

您可以使用 client.rename(oldFilePath,newFilePath, function (err, list) { ................................................. ..... } 其中 oldpath 将是您要复制文件的路径,例如 - /inside/old/file.csv 到要粘贴 /inside/new/file.csv 的位置

you can use the client.rename(oldFilePath,newFilePath, function (err, list) { ................. ................ } where the oldpath will be the path from where you want to copy the file, for example - /inside/old/file.csv to the place you want to paste /inside/new/file.csv

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文