11分钟学会Multipartfile与File类型转换
生命不是要超越别人,而是要超越自己
1、Multipartfile转File
File file = new File(path);
FileUtils.copyInputStreamToFile(multipartFile.getInputStream(), file);
2、File转Multipartfile
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));