Skip to content

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

@friendsWhat

Description

@friendsWhat

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions