Search code examples
node.jsftps

How to connect ftps using node and upload the files


I am new in node.js. I want to connect ftps://ftp.XXX.XXX using node.js in a passive mode. After a successful connection I want to upload local files to connected ftps.

My code below is working for the ftp but showing timeout for ftps://ftp.XXX.XXX.

var  Client = require('ssh2-sftp-client');

 const config = {
        host: 'XXX.XXXX.net',
        username: 'XXXXX',
        password: 'XXXXX',
        port: 22

      };
     let status= await sftp.connect(config)
    .then(() => {
        console.log('filename===>'+filename); 
        console.log('fullpath===>'+fullpath); 
        sftp.fastPut(fullpath, '/path/to/remote/dir'+filename);
        return 1;
    }).catch(err => {
       console.error(err.message);
        return 0;
    });

Solution

  • This issue has been resolve. Actually I am trying to connect box.com ftps account and they have provided the hooks on event of upload so I have used those hook to implement functionality