【发布时间】:2022-11-22 09:17:30
【问题描述】:
在 nestjs 应用程序中上传文件之前,我要验证多部分表单。问题是,如果正文验证失败,我不想上传文件。 这是我编写代码的方式。
// User controller method for create user with upload image
@Post()
@UseInterceptors(FileInterceptor('image'))
create(
@Body() userInput: CreateUserDto,
@UploadedFile(
new ParseFilePipe({
validators: [
// some validator here
]
})
) image: Express.Multer.File,
) {
return this.userService.create({ ...userInput, image: image.path });
}
尝试了很多方法来解决这个问题,但没有找到任何解决方案
【问题讨论】:
标签: node.js validation file-upload nestjs nest