/**
* file转MultipartFile
*
* @param file file
* @return MultipartFile
*/
public static MultipartFile fileToMultipartFile(File file) {
MultipartFile result = null;
if (null != file) {
try (FileInputStream input = new FileInputStream(file)) {
result = new MockMultipartFile(file.getName().concat("temp"), file.getName(), "text/plain", input);
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
file转MultipartFile
于 2024-01-10 10:33:58 首次发布