Commit 2ea05e35 authored by cuijun's avatar cuijun

文件压缩500图片格式

parent 539d5c33
...@@ -145,7 +145,8 @@ public class UploadService { ...@@ -145,7 +145,8 @@ public class UploadService {
redisTemplate.expire(redisNoKey, 1, TimeUnit.DAYS); redisTemplate.expire(redisNoKey, 1, TimeUnit.DAYS);
} }
String fileName = file.getOriginalFilename(); String fileName = file.getOriginalFilename();
String realFileRelPath = dirPathToday + "/" + no + fileName.substring(fileName.lastIndexOf(".")); String lastFormat = fileName.substring(fileName.lastIndexOf("."));
String realFileRelPath = dirPathToday + "/" + no + lastFormat;
// 文件存放路径 // 文件存放路径
String filePath = baseUploadPath + realFileRelPath; String filePath = baseUploadPath + realFileRelPath;
// 将文件写入指定位置 // 将文件写入指定位置
...@@ -172,8 +173,8 @@ public class UploadService { ...@@ -172,8 +173,8 @@ public class UploadService {
g.dispose(); g.dispose();
// 保存压缩后的图片 // 保存压缩后的图片
String compressedFilePath = baseUploadPath + dirPathToday + "/"+ no + ".jpg_250"; String compressedFilePath = baseUploadPath + dirPathToday + "/"+ no + lastFormat + "_250";
ImageIO.write(resizedImage, "jpg", new File(compressedFilePath)); ImageIO.write(resizedImage, lastFormat.substring(2, lastFormat.length()), new File(compressedFilePath));
realFileRelPath = xx_url + SystemConfig.XXMP_URL + realFileRelPath; realFileRelPath = xx_url + SystemConfig.XXMP_URL + realFileRelPath;
return realFileRelPath; return realFileRelPath;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment