var parse = require(‘co-busboy’) var path = require(‘path’)
app.use(function* (next) {
var ctx = this
var parts = parse(this, {
// only allow upload .jpg
files
checkFile: function (fieldname, file, filename) {
if (path.extname(filename) !== ‘.jpg’) {
var err = new Error(‘invalid jpg image’)
err.status = 400
return err
}
}
})
var part
while (part = yield parts) {
// …
}
})
while里面的代码进不去,就是part永远是null
Headers: x-authorization-token :ad279b8419b3f2094242e48303fa56cc2c40d115 Content-Type:multipart/form-data; boundary=--------------------56423498738365
Body: binary 选择了一张图片