文件上传接口传参规范
单个文件上传
@RequestBody与文件类型参数不兼容:
org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;
@PostMapping("/fileUpload")
public void method(@RequestBody @Validated FileMultipartUploadReqVO reqVO,
@RequestParam(value = "file") MultipartFile file) {}
//把@RequestBody去掉
@PostMapping("/fileUpload")
public void method(@Validated FileMultipartUploadReqVO reqVO,
@RequestParam(value = "file") MultipartFile file) {}
批量文件上传
@PostMapping("/fileUpload")
public void method(@Validated FileMultipartUploadReqVO reqVO,
@RequestParam(value = "fileList") List<MultipartFile> fileList) {}
//注意:前端此时批量上传时需要将fileList并列传到body的form-data中,并不是像后端一样放到一个集合中