MultipartFile文件转换File文件
public static File toFile(MultipartFile multipartFile) throws IOException {
InputStream ins = multipartFile.getInputStream();
File toFile = new File(multipartFile.getOriginalFilename());
try {
OutputStream os = new FileOutputStream(toFile);
int bytesRead;
byte[] buffer = new byte[8192];
while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
os.write(buffer, 0, bytesRead);
}
os.close();
ins.close();
} catch (Exception e) {
e.printStackTrace();
}finally {
return toFile;
}
}