2 Commity a0def02e06 ... 0ee83bb65f

Autor SHA1 Wiadomość Data
  reghao 0ee83bb65f 更新 ConsoleServiceImpl#registerAndBind 方法中根据 contentType 指定 ObjectType 中的 fileType 2 dni temu
  reghao a28422738c update ConsoleServiceImpl#getObjectMeta 2 dni temu

+ 9 - 4
oss-mgr/src/main/java/cn/reghao/oss/mgr/rpc/ConsoleServiceImpl.java

@@ -76,8 +76,10 @@ public class ConsoleServiceImpl implements ConsoleService {
     @Override
     public void registerAndBind(UploadResult uploadResult) {
         String contentType = uploadResult.getContentType();
-        int fileType = ObjectType.Any.getValue();
-        if (contentType.startsWith("video")) {
+        int fileType = ObjectType.Other.getValue();
+        if (contentType.startsWith("image")) {
+            fileType = ObjectType.Image.getValue();
+        } else if (contentType.startsWith("video")) {
             fileType = ObjectType.Video.getValue();
         } else if (contentType.startsWith("audio")) {
             fileType = ObjectType.Audio.getValue();
@@ -91,8 +93,6 @@ public class ConsoleServiceImpl implements ConsoleService {
             fileType = ObjectType.DocExcel.getValue();
         } else if (contentType.equals("application/vnd.openxmlformats-officedocument.presentationml.presentation")) {
             fileType = ObjectType.DocPpt.getValue();
-        }  else if (contentType.startsWith("application/")) {
-            fileType = ObjectType.Other.getValue();
         }
 
         long uploadBy = uploadResult.getUploadBy();
@@ -127,6 +127,11 @@ public class ConsoleServiceImpl implements ConsoleService {
     @Override
     public ObjectMeta getObjectMeta(String httpHost, String objectName) {
         UserNode userNode = userNodeService.getUserNodeByDomain(httpHost);
+        if (userNode == null) {
+            log.error("userNodenot found with  {} and {}", httpHost, objectName);
+            return null;
+        }
+
         long uploadBy = userNode.getCreateBy();
         return objectRepository.getObjectMetaByName(objectName, uploadBy);
     }