node.js - 如何使用node连接ftp并上传文件

标签 node.js ftps

我是 Node.js 新手。我想在被动模式下使用node.js连接ftps://ftp.XXX.XXX。连接成功后,我想将本地文件上传到连接的 ftps。

下面的代码适用于 ftp,但显示 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;
    });

最佳答案

此问题已解决。实际上我正在尝试连接box.com ftps 帐户,他们提供了上传事件的 Hook ,因此我使用这些 Hook 来实现功能

关于node.js - 如何使用node连接ftp并上传文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59283755/

相关文章:

java - Camel FTPS组件自动创建目录

javascript - 如何在 Node.js 中的同一进程内监听同一地址上的不同 UDP 端口

mysql - 如何在 Moleculer.js 中使用 Sequelize ORM 原始查询(内联或已经准备好的 SQL 查询)

authentication - 通过代理身份验证的 FTPS

ssl - FTP 密码加密

azure - Azure VM 上的隐式 tls proftpd 连接被拒绝

node.js - 在 Windows 7 中安装 Express.JS 的问题

node.js - 如何调试此 Webpack 错误 - 来自 Terser 的 bundle.js 中的错误

node.js - 在node.js中如何获取请求对象的协议(protocol)?

file - cURL - 使用 cURL 来 ftp 文件并保留文件的原始时间戳