/**
*上传图片
* @param savePath
* @return
* @throws Exception
*/
public String saveImage(String savePath, File imagePath,String imagePathFileName)throws Exception{
StringBuffer sb = new StringBuffer();
String path = "";
if(null != imagePath && !"".equals(imagePath)){
sb.append(savePath);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");
sb.append(simpleDateFormat.format(new Date()));
String uploadPath = sb.toString();
File uploadFile = new File(uploadPath);
if(!uploadFile.exists()){
uploadFile.mkdirs();
}
String imageName = UUID.randomUUID().toString()+imagePathFileName.subSequence(imagePathFileName.lastIndexOf("."), imagePathFileName.length());
imageName = imageName.replace("|", "_");
File saveFile = new File(uploadFile, imageName);
FileUtils.copyFile(imagePath, saveFile);
path = sb.toString()+"/"+imageName;
}
if(StringUtils.isNotBlank(path)){
path = path.replace(EopSetting.IMG_SAVE_PATH +"/statics", "");
path = EopSetting.UPLOAD_IMG_SERVER_DOMAIN+ path;
}
logger.info("====upload image url : " + path);
return path;
}