public static File multipartFileToFile(MultipartFile multiFile) {
// 获取文件名
String fileName = multiFile.getOriginalFilename();
if (StringUtils.isNullOrEmpty(fileName)) {
return null;
}
// 获取文件后缀
String prefix = fileName.substring(fileName.lastIndexOf("."));
try {
File file = File.createTempFile(fileName, prefix);
multiFile.transferTo(file);
return file;
} catch (Exception e) {
log.error("MultipartFile转换为File转换异常:" + e.getMessage());
}
return null;
}