[英]Uploading on a FTP server NodeJS : Error
I am using https://github.com/mscdex/node-ftp to upload a file on a FTP server. 我正在使用https://github.com/mscdex/node-ftp将文件上传到FTP服务器上。 Here is my code:
这是我的代码:
const Client = require('ftp');
console.log('CONNECTING...')
const c = new Client();
c.on('ready', function () {
console.log('READY');
c.put('test.csv','test.remote-copy.csv',function (err) {
if (err) { console.log('PUT err : ' + err); };
c.end();
});
});
// connect to ftp server
c.connect({
host: "my-adress",
port: 22,
user: "my-user",
password: "my-pass",
debug: console.log
});
console.log(c);
In the log of c, the config is well set but is says connected false, however I use exactly the same username/password on FileZilla and it works fine : 在c的日志中,配置设置正确,但是说连接错误,但是我在FileZilla上使用完全相同的用户名/密码,并且工作正常:
options:
{ host: 'my-address',
port: 22,
user: 'my-user',
password: 'my-pass',
secure: false,
secureOptions: undefined,
connTimeout: 10000,
pasvTimeout: 10000,
aliveTimeout: 10000 },
connected: false,
_events: { ready: [Function] },
_eventsCount: 1 }
I just found my mistake and feel idiot, it is just that I used a ftp package but my server was in SFTP. 我只是发现了自己的错误并且觉得很蠢,只是我使用了ftp程序包,但是我的服务器在SFTP中。 If you have the same problem use this package and it works perfectly : https://www.npmjs.com/package/ssh2-sftp-client
如果您有相同的问题,请使用此软件包,它可以正常工作: https : //www.npmjs.com/package/ssh2-sftp-client
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.