ftpimp icon indicating copy to clipboard operation
ftpimp copied to clipboard

Username With \ not work

Open andrebassi opened this issue 7 years ago • 1 comments

I try this username Azure format: appservice\username and return me:


handle.data.waiting: false 331 ....................

331 Password required

331

andrebassi avatar Aug 31 '17 19:08 andrebassi

Thanks for reporting the issue, Azure has a free tier, if I have time I will try to add support. Can you try this and share your results? You'll need to update the configuration object.

/** Add your config **/
var config = {
  host: 'localhost',
  port: 21,
  user: 'root',
  pass: '',
  debug: true
};
const FTP = require('ftpimp');
const ftp = FTP.create(config, false);
//add the code to handle requesting a password
ftp.cmd.codes[331] = 'sendPass';
//change login to only send user
ftp.cmd.login = ftp.user(ftp.config.user, (err, data) => {
  if (err) {
    return console.log(err);
  }
  console.log('user sent');
});
//attach sendPass so that when 331 comes in, this method is triggered
ftp.cmd.sendPass = function () {
  console.log('sending pass');
  ftp.pass(ftp.config.pass, function (err, data) {
    if (err) {
      return console.log(err);
    }
    console.log('password sent');
    ftp.raw('CWD', function (res) {
      var dir = res.indexOf('/');
      dir = res.slice(dir - 1).trim();
      ftp.cwd = ftp.baseDir = dir;
      console.log('current dir: ' + ftp.cwd);
      ftp.emit('ready');
      ftp.isReady = true;
    });
  });
};

sparkida avatar Feb 07 '18 11:02 sparkida