按照官方给的这个例子去做https://github.com/koajs/examples/blob/master/upload/index.js 可是总是获取不到上传的内容,进入不到while里面:
app.use(function *(next){
// ignore non-POSTs
if ('POST' != this.method) return yield next;
// multipart upload
var parts = parse(this);
var part;
while (part = yield parts) {
var stream = fs.createWriteStream('/tmp/' + Math.random());
part.pipe(stream);
console.log('uploading %s -> %s', part.filename, stream.path);
}
this.redirect('/');
});
12 回复