特殊情况下需要做转换
1、M转F
File file = new File(path);
FileUtils.copyInputStreamToFile(multipartFile.getInputStream(), file);
2、F转M
File file = new File("src/test/resources/input.txt");
FileInputStream input = new FileInputStream(file);
MultipartFile multipartFile =new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(input));
来源:Multipartfile与File类型相互转换_qiao_w的博客-CSDN博客_multiplefile转file