🐛 https://github.com/rymcu/forest/issues/63
This commit is contained in:
commit
16ad1d32e6
@ -7,7 +7,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件操作工具类
|
* 文件操作工具类
|
||||||
@ -35,13 +34,20 @@ public class FileUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getExtend(String filename, String defExt) {
|
public static String getExtend(String filename, String defExt) {
|
||||||
if ((filename != null) && (filename.length() > 0)) {
|
if (StringUtils.isEmpty(filename)) {
|
||||||
int i = filename.lastIndexOf('.');
|
return defExt.toLowerCase();
|
||||||
|
|
||||||
if ((i > 0) && (i < (filename.length() - 1))) {
|
|
||||||
return (filename.substring(i + 1)).toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int i = filename.lastIndexOf('.');
|
||||||
|
|
||||||
|
if ((i > 0) && (i < (filename.length() - 1))) {
|
||||||
|
String result = filename.substring(i + 1).toLowerCase();
|
||||||
|
if (result.contains("?")) {
|
||||||
|
return result.split("\\?")[0];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
return defExt.toLowerCase();
|
return defExt.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,8 +187,7 @@ public class UploadController {
|
|||||||
|
|
||||||
String localPath = Utils.getProperty("resource.file-path") + "/" + typePath + "/";
|
String localPath = Utils.getProperty("resource.file-path") + "/" + typePath + "/";
|
||||||
|
|
||||||
String orgName = url.substring(url.lastIndexOf("."));
|
String fileName = System.currentTimeMillis() + "." + FileUtils.getExtend(url);
|
||||||
String fileName = System.currentTimeMillis() + FileUtils.getExtend(orgName).toLowerCase();
|
|
||||||
|
|
||||||
String savePath = file.getPath() + File.separator + fileName;
|
String savePath = file.getPath() + File.separator + fileName;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user