对于某些缓存文件信息敏感,需反复擦除
@PostMapping("upload")
public Object up(HttpServletRequest request){
Object obj = null;
File file = null;
try {
MultipartHttpServletRequest request1 = (MultipartHttpServletRequest) request;
MultipartFile multipartFile = request1.getFile("file");
ApplicationPart part = (ApplicationPart)request1.getPart("file");
Class> Clazz = part.getClass();
Field field;
if ((field = getField(Clazz, "location")) != null){
field.setAccessible(true);
try {
obj = field.get(part);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
file = (File) obj;
if ((field = getField(Clazz, "fileItem")) != null){
field.setAccessible(true);
try {
obj = field.get(part);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
file = (File) obj;
DiskFileItem fileItem =(DiskFileItem)obj;
log.info(fileItem.getStoreLocation().toString());
log.info(obj.toString());
log.info(file.getAbsolutePath());
log.info(file.getName());
log.info(file.getCanonicalPath());
} catch (IOException e) {
e.printStackTrace();
return file;
} catch (ServletException e) {
e.printStackTrace();
return file;
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return file;
}



