Reputation: 420
I am using https://github.com/mscdex/node-ftp to upload a file on a FTP server. 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 :
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 }
Upvotes: 0
Views: 5239
Reputation: 420
I just found my mistake and feel idiot, it is just that I used a ftp package but my server was in SFTP. If you have the same problem use this package and it works perfectly : https://www.npmjs.com/package/ssh2-sftp-client
Upvotes: 2