[fixed] getRelFilePath 返回null 导致KkFileUtils.isAllowedUpload的空指针异常

pull/217/head
lujiaming 2023-08-21 14:44:20 +08:00
parent da784aea84
commit d8146f0495
1 changed files with 7 additions and 7 deletions

View File

@ -49,7 +49,13 @@ public class DownloadUtils {
}
ReturnResponse<String> response = new ReturnResponse<>(0, "下载成功!!!", "");
String realPath = getRelFilePath(fileName, fileAttribute);
if (null == realPath || !KkFileUtils.isAllowedUpload(realPath)) {
if(!StringUtils.hasText(realPath)){
response.setCode(1);
response.setContent(null);
response.setMsg("下载失败:文件名不合法!" + urlStr);
return response;
}
if (!KkFileUtils.isAllowedUpload(realPath)) {
response.setCode(1);
response.setContent(null);
response.setMsg("下载失败:不支持的类型!" + urlStr);
@ -61,12 +67,6 @@ public class DownloadUtils {
response.setMsg(fileName);
return response;
}
if(!StringUtils.hasText(realPath)){
response.setCode(1);
response.setContent(null);
response.setMsg("下载失败:文件名不合法!" + urlStr);
return response;
}
if(realPath.equals("cunzhai")){
response.setContent(fileDir + fileName);
response.setMsg(fileName);