frontend is vue4, backend is SpringBoot2.1.4
when one file and multiple parameters, you can use
@PostMapping("/xxx/uploadFile")
@ResponseBody
public CommonResult<String> createHomework(@RequestPart("token") String token, @RequestPart("class") String classId, @RequestPart("classDate") String classDate, @RequestPart("file") @Valid @NotNull @NotBlank MultipartFile dataFile)
It runs ok
but when you try upload multiple files
public CommonResult<String> createClass(@RequestPart("token") String token,
@RequestPart("class") String classId, @RequestPart("classDate") String classDate,
@RequestParam("file1") @Valid @NotNull @NotBlank MultipartFile file1,
@RequestParam("file2") @Valid @NotNull @NotBlank MultipartFile file2)
it will throw exception:
HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported]
you can remove the @RequestPart for the parameters, then it will be ok:
public CommonResult<String> createClass(String token, String classId, String classDate,
@RequestParam("file1") @Valid @NotNull @NotBlank MultipartFile file1,
@RequestParam("file2") @Valid @NotNull @NotBlank MultipartFile file2)