//将图片存储成文件
public String Convert(Object requestFile, String abslutePath) {
if (requestFile == null) {
return null;
}
String originName = "";
if (requestFile instanceof MultipartFile) {
MultipartFile attchment = (MultipartFile) requestFile;
originName = attchment.getOriginalFilename();
File file = new File(abslutePath + originName);
if (!file.exists()) {
file.mkdirs();
}
try {
attchment.transferTo(new File(abslutePath + originName));
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return originName;
}
java 将图片转储成为文件
最新推荐文章于 2023-04-11 18:50:41 发布