|
@ -132,37 +132,37 @@ public class CommonUtil {
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
public static String copyTempImage(String images) throws IOException {
|
|
|
// 文件保存的临时路径
|
|
|
String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
|
|
|
// 图片保存路径
|
|
|
String imagePath = SystemConf.getInstance().getImagePath() + File.separator;
|
|
|
String[] tempImages = images.split(",");
|
|
|
String temp = "";
|
|
|
for (String image : tempImages) {
|
|
|
File file = new File(tempPath + image);
|
|
|
File smallFile = new File(tempPath + image + "_small");
|
|
|
if (file.exists() && smallFile.exists()) {
|
|
|
// 原图拷贝路径
|
|
|
File targetFile = new File(imagePath + image);
|
|
|
// 缩略图拷贝路径
|
|
|
File targetSmallFile = new File(imagePath + image + "_small");
|
|
|
// 拷贝原图
|
|
|
FileUtils.copyFile(file, targetFile);
|
|
|
// 拷贝缩略图
|
|
|
FileUtils.copyFile(smallFile, targetSmallFile);
|
|
|
// 删除临时文件
|
|
|
FileUtils.forceDelete(file);
|
|
|
FileUtils.forceDelete(smallFile);
|
|
|
if (temp.length() == 0) {
|
|
|
temp = SystemConf.getInstance().getImageServer() + image;
|
|
|
} else {
|
|
|
temp += "," + SystemConf.getInstance().getImageServer() + image;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return temp;
|
|
|
}
|
|
|
// public static String copyTempImage(String images) throws IOException {
|
|
|
// // 文件保存的临时路径
|
|
|
// String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
|
|
|
// // 图片保存路径
|
|
|
// String imagePath = SystemConf.getInstance().getImagePath() + File.separator;
|
|
|
// String[] tempImages = images.split(",");
|
|
|
// String temp = "";
|
|
|
// for (String image : tempImages) {
|
|
|
// File file = new File(tempPath + image);
|
|
|
// File smallFile = new File(tempPath + image + "_small");
|
|
|
// if (file.exists() && smallFile.exists()) {
|
|
|
// // 原图拷贝路径
|
|
|
// File targetFile = new File(imagePath + image);
|
|
|
// // 缩略图拷贝路径
|
|
|
// File targetSmallFile = new File(imagePath + image + "_small");
|
|
|
// // 拷贝原图
|
|
|
// FileUtils.copyFile(file, targetFile);
|
|
|
// // 拷贝缩略图
|
|
|
// FileUtils.copyFile(smallFile, targetSmallFile);
|
|
|
// // 删除临时文件
|
|
|
// FileUtils.forceDelete(file);
|
|
|
// FileUtils.forceDelete(smallFile);
|
|
|
// if (temp.length() == 0) {
|
|
|
// temp = SystemConf.getInstance().getImageServer() + image;
|
|
|
// } else {
|
|
|
// temp += "," + SystemConf.getInstance().getImageServer() + image;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// return temp;
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
* 拷贝临时语音文件到存储目录
|
|
@ -227,7 +227,7 @@ public class CommonUtil {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public static String copyTempFilesToFastDFS(String files) throws Exception {
|
|
|
public static String copyTempImage(String files) throws Exception {
|
|
|
// 文件保存的临时路径
|
|
|
String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
|
|
|
String[] fileArray = files.split(",");
|
|
@ -236,13 +236,18 @@ public class CommonUtil {
|
|
|
|
|
|
for (String file : fileArray) {
|
|
|
File f = new File(tempPath + file);
|
|
|
File fs = new File(tempPath + file + "_small");
|
|
|
if (f.exists()) {
|
|
|
String fileName = f.getName();
|
|
|
InputStream in = new FileInputStream(f);
|
|
|
ObjectNode result = fastDFSUtil.upload(in, fileName.substring(fileName.lastIndexOf(".") + 1), "");
|
|
|
in.close();
|
|
|
if (result != null) {
|
|
|
fileUrls += (StringUtils.isEmpty(fileUrls) ? "" : ",") + result.get("fileUrl").toString().replaceAll("\"","");
|
|
|
fileUrls += (StringUtils.isEmpty(fileUrls) ? "" : ",") + result.get("fileUrl").toString().replaceAll("\"", "");
|
|
|
f.delete();
|
|
|
if (fs.exists()) {
|
|
|
fs.delete();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|