简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM