reghao 1 هفته پیش
والد
کامیت
ba5dfbb5aa

+ 2 - 0
oss-api/src/main/java/cn/reghao/oss/api/dto/rest/FastUploadResult.java

@@ -22,6 +22,7 @@ public class FastUploadResult implements Serializable {
     private String filename;
     private String objectId;
     private String objectName;
+    private String channelPrefix;
     private long uploadBy;
 
     public FastUploadResult(UploadResult uploadResult) {
@@ -29,6 +30,7 @@ public class FastUploadResult implements Serializable {
         this.filename = uploadResult.getFilename();
         this.objectId = uploadResult.getObjectId();
         this.objectName = uploadResult.getObjectName();
+        this.channelPrefix = uploadResult.getChannelPrefix();
         this.uploadBy = uploadResult.getUploadBy();
     }
 }

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

@@ -65,7 +65,10 @@ public class ConsoleServiceImpl implements ConsoleService {
         }
 
         FileMeta fileMeta0 = list.getFirst();
-        ObjectScope objectScope = ObjectScope.PUBLIC;
+        long uploadBy = fastUploadResult.getUploadBy();
+        String channelPrefix = fastUploadResult.getChannelPrefix();
+        UploadChannel uploadChannel = uploadChannelService.getByChannelPrefixAndCreateBy(channelPrefix, uploadBy);
+        ObjectScope objectScope = ObjectScope.getByCode(uploadChannel.getScope());
         FileMeta fileMeta = new FileMeta(fastUploadResult, fileMeta0, objectScope);
         objectRepository.saveFileMeta(fileMeta);
     }

+ 2 - 1
oss-store/src/main/java/cn/reghao/oss/store/handler/OssUploadHandler.java

@@ -89,7 +89,8 @@ public class OssUploadHandler extends SimpleChannelInboundHandler<HttpObject> {
             String objectName = String.format("%s%s.%s", channelPrefix, objectId, suffix);
             long uploadBy = (Long) ctx.channel().attr(AttributeKey.valueOf("uploadBy")).get();
             if (clientSha256 != null && consoleService.checkExists(clientSha256)) {
-                FastUploadResult fastUploadResult = new FastUploadResult(clientSha256, filename, objectId, objectName, uploadBy);
+                FastUploadResult fastUploadResult =
+                        new FastUploadResult(clientSha256, filename, objectId, objectName, channelPrefix, uploadBy);
                 consoleService.bindOnly(fastUploadResult);
                 String uploadId = fastUploadResult.getObjectId();