Mukesh Kashyap
Mukesh Kashyap

Reputation: 899

Module to move file from one directory to another on ftp server using nodejs

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);
    });
  });

Upvotes: 0

Views: 1036

Answers (1)

Mukesh Kashyap
Mukesh Kashyap

Reputation: 899

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

Upvotes: 1

Related Questions