Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the part.length is undefined and can't catch error #22

Open
friendsWhat opened this issue May 20, 2015 · 0 comments
Open

the part.length is undefined and can't catch error #22

friendsWhat opened this issue May 20, 2015 · 0 comments

Comments

@friendsWhat
Copy link


var parse = require('co-busboy');
app.use(function* (next) {
  if (!this.request.is('multipart/*')) return yield next;
  var parts = parse(this, {
          checkFile: function (fieldname, filestream, filename) {
          if (path.extname(filename) !== '.dat') {
            return new Error('invalid filename extension');
          }
        }
   });
  var part;
try {
  while (part = yield parts) {
    if (part.length) {
      console.log('key: ' + part[0]);
      console.log('value: ' + part[1]);
    } else {
      part.pipe(fs.createWriteStream('some file.txt'))
    }
  }
catch (e) {
}
});

when upload a image file, the 'part' is FileStream instance.but it is no length method.
and then can't catch checkFile error. my request url's status always 'pending'.
i don't know why, pls help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant