一、 CommonsMultipartFile转为File(曲线救国)
此处用曲线救国的方式:先用CommonsMultipartFile的getInputStream()方法获取到一个InputStream类型的对象,再将InputStream类型转化为File
//将InputStream类型转化为File类型
private static void inputStreamToFile(InputStream ins, File file) {
//将输出流转化为文件即可
FileOutputStream os = null;
try {
os = new FileOutputStream(file);
int bytesRead = 0;
byte[] buffer = new byte[1024];
while((bytesRead = ins.read(buffer)) != -1) {
os.write(buffer, 0, bytesRead);
}
}catch(Exception e) {
throw new