Commit 2ea05e35 authored by cuijun's avatar cuijun

文件压缩500图片格式

parent 539d5c33
......@@ -145,7 +145,8 @@ public class UploadService {
redisTemplate.expire(redisNoKey, 1, TimeUnit.DAYS);
}
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;
// 将文件写入指定位置
......@@ -172,8 +173,8 @@ public class UploadService {
g.dispose();
// 保存压缩后的图片
String compressedFilePath = baseUploadPath + dirPathToday + "/"+ no + ".jpg_250";
ImageIO.write(resizedImage, "jpg", new File(compressedFilePath));
String compressedFilePath = baseUploadPath + dirPathToday + "/"+ no + lastFormat + "_250";
ImageIO.write(resizedImage, lastFormat.substring(2, lastFormat.length()), new File(compressedFilePath));
realFileRelPath = xx_url + SystemConfig.XXMP_URL + 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