-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Stream模式下多文件上传 如何先通过validate验证下参数 再决定上传否 #5311
Comments
想先对其他上传的字段做个验证 再决定接受是否上传的文件 stream模式下能做到吗? |
await parts 就是一个个的拿的,但你验证后会做些啥?如果是为了中断请求节省资源,好像也提升不了多少。 |
上传到s3的名字会拿field。比如version,type。接口不仅给前端使用,其他服务端可能集成在ci里。 |
我的意思是,直接 file mode 存到临时文件后,一起处理也可以吧,你这里的原始需求是啥 |
Streams能做到file mode一样一起处理 的吗 |
当然可以,file mode 底层就是 stream mode,你看下源码就知道了。 |
看了busboy的代码,好像能这样校验。 let parts = this.ctx.multipart({ autoFields: true,
checkField: (name, value) => {
if (name === '_csrf' && !checkCSRF(ctx, value)) {
var err = new Error('invalid csrf token')
err.status = 400
return err
}
}
}); |
let parts = this.ctx.multipart({ autoFields: true });
let files = [];
let stream;
// field 能提前获取到值吗
const field = parts.field
while ((stream = await parts()) != null) {
// xxx
}
The text was updated successfully, but these errors were encountered: