我是 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/