Monday, 17 April 2017

Nodejs - catch upload to ftp error(ftp module)

How can I catch an upload error in node js via ftp? For example when my computer loses the connection. I am using ftp module and nothing of this(error, close or end) throws any errors.

var Client = require('ftp');
var c = new Client();

c.on('ready', callback);
c.on('error', function(err){
    console.log(err);
});
c.on('close', function(err){
    console.log(err);
});
c.on('end', function(){
    console.log("END");
});

c.connect({
    host: host,
    port: port,
    user: username,
    password: password
});
...
c.put(uploadfile, uploadpath, onupload);



via Kirill

No comments:

Post a Comment