realtymaps/promise-ftp

unable to call the method as prototype

aakashkumar667 opened this issue · 1 comments

Hi Team,
I need your help my code is as shown below,

var PromiseFtp = require('promise-sftp');

var ftp = new PromiseFtp();

ftp.connect({host: 'host', user: 'username', password: 'password'});

ftp.readdir('/')

I am getting the following error
Unhandled rejection FtpConnectionError: can't perform 'readdir' command when connection status is: not yet connected

but i want to create one user per session I do not want to access like a constructor, please help on same

I suggest you look into how promises work -- see http://bluebirdjs.com/docs/why-promises.html as a starting place.

You need to chain your commands together, promise-style. Try this instead:

ftp.connect({host: 'host', user: 'username', password: 'password'})
.then(function () {
  ftp.readdir('/')
})