Browse Source

解决因为没有扩展名复制报错的BUG

wukai 1 year ago
parent
commit
8cc342d935
1 changed files with 10 additions and 7 deletions
  1. 10 7
      doc-biz/src/main/java/com/doc/biz/controller/DocInfoController.java

+ 10 - 7
doc-biz/src/main/java/com/doc/biz/controller/DocInfoController.java

@@ -177,13 +177,16 @@ public class DocInfoController extends BaseController {
         if (info == null) {
             return error("该文件已失效!");
         }
+
         String ext = info.getFileType();
-        //因为数据库存的是带 . 的,所以要先截取掉这个 .
-        ext = ext.substring(1);
-        if (Arrays.asList(Constants.ALLOW_EDIT).contains(ext)) {
-            //判断是否 onlyoffice允许的可编辑文件格式,如果是,则需要复制一份,如果不是就不管
-            DocumentVO vo = mongoService.copy(info.getFileId());
-            info.setFileId(vo.getFileId());
+        if (StringUtils.isNotEmpty(ext)) {
+            //因为数据库存的是带 . 的,所以要先截取掉这个 .
+            ext = ext.substring(1);
+            if (Arrays.asList(Constants.ALLOW_EDIT).contains(ext)) {
+                //判断是否 onlyoffice允许的可编辑文件格式,如果是,则需要复制一份,如果不是就不管
+                DocumentVO vo = mongoService.copy(info.getFileId());
+                info.setFileId(vo.getFileId());
+            }
         }
 
         info.setDocId(null);
@@ -192,7 +195,7 @@ public class DocInfoController extends BaseController {
         info.setFileName(info.getFileName());
         docInfoService.insertDocInfo(info);
 
-        return success();
+        return success(info);
     }