陈精华 2023-06-29 11:07:50 +08:00
parent 8bb0f3a066
commit 2e9062d377
No known key found for this signature in database
GPG Key ID: 30BDC970902B755D
2 changed files with 6 additions and 17 deletions

View File

@ -355,6 +355,12 @@ public class FileHandlerService {
fileName = fullFileName;
type = FileType.typeFromFileName(fullFileName);
suffix = KkFileUtils.suffixFromFileName(fullFileName);
// 移除fullfilename参数
if (url.indexOf("fullfilename=" + fullFileName + "&") > 0) {
url.replace("fullfilename=" + fullFileName + "&", "");
} else {
url.replace("fullfilename=" + fullFileName, "");
}
} else {
fileName = WebUtils.getFileNameFromURL(url);
type = FileType.typeFromUrl(url);

View File

@ -154,23 +154,6 @@ public class WebUtils {
*/
public static String encodeUrlFileName(String url) {
String encodedFileName;
String fullFileName = WebUtils.getUrlParameterReg(url, "fullfilename");
if (fullFileName != null && fullFileName.length() > 0) {
try {
encodedFileName = URLEncoder.encode(fullFileName, "UTF-8");
} catch (UnsupportedEncodingException e) {
return null;
}
String urlStrr = url.toLowerCase(); //转换为小写对比
boolean wjl =kuayu("&fullfilename=", urlStrr); //判断是否启用文件流
if(wjl){
url = url.substring(0,url.lastIndexOf("&")); //删除添加的文件流内容
}
String noQueryUrl = url.substring(0, url.indexOf("?"));
String parameterStr = url.substring(url.indexOf("?"));
parameterStr = parameterStr.replaceFirst(fullFileName, encodedFileName);
return noQueryUrl + parameterStr;
}
String noQueryUrl = url.substring(0, url.contains("?") ? url.indexOf("?") : url.length());
int fileNameStartIndex = noQueryUrl.lastIndexOf('/') + 1;
int fileNameEndIndex = noQueryUrl.lastIndexOf('.');