Node.js connect to ftp and upload files

Hi i downloaded this npm module to connect to my ftp: node-ftps

connection class

var FTPS = require('ftps');
var ftps = new FTPS({
  host: 'myhost',
  username: 'user',
  password: 'mypw',
  protocol: 'ftp'
});

ftps.exec(function (err, res) {
  console.log();
});

      

how can i check if the connection was successful and how can i get all files from my path?

tried adding a file but getting an error, i didn't even know if i was connected to it

+3


source to share


1 answer


I would advise you to try node-ftp

, which supports ftps

too. While node-ftps

doing the same job, it lacks good documentation and examples.

Checkout here.

https://github.com/mscdex/node-ftp

To set up a connection and access its functionality, all you have to do is load a named node wrapper ftp-client

that is designed exclusively for the module node-ftp

.

You can install this shell by running the following command:

npm install ftp-client

      



Use the following command to initialize:

var ftpClient = require('ftp-client'),
client = new ftpClient(config, options);

      

And here you can find a complete example code that tells how we can connect to the server and download all files from the directory at the same time test

, overwriting only the old files found on the server and download files from /public_html/test directory

.

https://github.com/noodny/node-ftp-client#examples

Hope this helps!

+6


source







All Articles