瀏覽代碼

!217 [fixed] getRelFilePath 返回null 导致KkFileUtils.isAllowedUpload的空指针异常修复
Merge pull request !217 from lujiaming/master

kailing 1 年之前
父節點
當前提交
096426b8e2
共有 1 個文件被更改,包括 6 次插入6 次删除
  1. 6 6
      server/src/main/java/cn/keking/utils/DownloadUtils.java

+ 6 - 6
server/src/main/java/cn/keking/utils/DownloadUtils.java

@@ -49,6 +49,12 @@ public class DownloadUtils {
         }
         ReturnResponse<String> response = new ReturnResponse<>(0, "下载成功!!!", "");
         String realPath = getRelFilePath(fileName, fileAttribute);
+        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);
@@ -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);