优化图片
This commit is contained in:
parent
64b8271532
commit
159122ae7f
|
|
@ -112,6 +112,14 @@ public class FileUploadUtils
|
||||||
assertAllowed(file, allowedExtension);
|
assertAllowed(file, allowedExtension);
|
||||||
|
|
||||||
String fileName = extractFilename(file);
|
String fileName = extractFilename(file);
|
||||||
|
//把后缀都改成.png
|
||||||
|
int lastIndex = fileName.lastIndexOf('.');
|
||||||
|
|
||||||
|
if (lastIndex != -1) {
|
||||||
|
fileName = fileName.substring(0, lastIndex + 1) + "png";
|
||||||
|
}else {
|
||||||
|
fileName = fileName + "." + "png";
|
||||||
|
}
|
||||||
|
|
||||||
String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
|
String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
|
||||||
file.transferTo(Paths.get(absPath));
|
file.transferTo(Paths.get(absPath));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue