瀏覽代碼

将 acl 字段修改为 scope

reghao 2 年之前
父節點
當前提交
385ab035e2
共有 18 個文件被更改,包括 101 次插入192 次删除
  1. 19 79
      dfs-store/src/main/java/cn/reghao/dfs/store/controller/ObjectUploadController.java
  2. 1 1
      dfs-store/src/main/java/cn/reghao/dfs/store/db/mapper/FileMetaMapper.java
  3. 23 30
      dfs-store/src/main/java/cn/reghao/dfs/store/db/repository/ObjectRepository.java
  4. 4 4
      dfs-store/src/main/java/cn/reghao/dfs/store/inerceptor/AccessLogInterceptor.java
  5. 7 7
      dfs-store/src/main/java/cn/reghao/dfs/store/model/po/FileMeta.java
  6. 1 1
      dfs-store/src/main/java/cn/reghao/dfs/store/model/vo/ObjectProp.java
  7. 2 2
      dfs-store/src/main/java/cn/reghao/dfs/store/rpc/ObjectServiceImpl.java
  8. 2 2
      dfs-store/src/main/java/cn/reghao/dfs/store/rpc/PermissionServiceImpl.java
  9. 2 2
      dfs-store/src/main/java/cn/reghao/dfs/store/service/ObjectMultipartUploadService.java
  10. 11 9
      dfs-store/src/main/java/cn/reghao/dfs/store/service/ObjectNameService.java
  11. 9 32
      dfs-store/src/main/java/cn/reghao/dfs/store/service/PutObjectService.java
  12. 3 3
      dfs-store/src/main/java/cn/reghao/dfs/store/task/AudioFileProcessor.java
  13. 1 1
      dfs-store/src/main/java/cn/reghao/dfs/store/task/DiskFileProcessor.java
  14. 4 4
      dfs-store/src/main/java/cn/reghao/dfs/store/task/ImageFileProcessor.java
  15. 2 2
      dfs-store/src/main/java/cn/reghao/dfs/store/task/VideoFileProcessor.java
  16. 8 8
      dfs-store/src/main/resources/mapper/FileMetaMapper.xml
  17. 1 1
      oss-api/src/main/java/cn/reghao/oss/api/dto/ObjectPrefix.java
  18. 1 4
      oss-api/src/main/java/cn/reghao/oss/api/rest/UploadFileRet.java

+ 19 - 79
dfs-store/src/main/java/cn/reghao/dfs/store/controller/ObjectUploadController.java

@@ -9,8 +9,6 @@ import cn.reghao.dfs.store.service.ObjectNameService;
 import cn.reghao.dfs.store.service.PutObjectService;
 import cn.reghao.dfs.store.task.FileProcessor;
 import cn.reghao.dfs.store.util.JwtUtil;
-import cn.reghao.dfs.store.util.ObjectUtil;
-import cn.reghao.dfs.store.util.StringUtil;
 import cn.reghao.dfs.store.util.UserContext;
 import cn.reghao.jutil.jdk.result.WebResult;
 import cn.reghao.jutil.jdk.security.DigestUtil;
@@ -18,15 +16,10 @@ import cn.reghao.jutil.web.ServletUtil;
 import cn.reghao.oss.api.dto.OssPayload;
 import cn.reghao.oss.api.rest.UploadFileRet;
 import org.apache.commons.io.FileUtils;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.servlet.http.HttpServletRequest;
 import java.io.File;
-import java.io.FileInputStream;
 import java.util.UUID;
 
 /**
@@ -53,73 +46,13 @@ public class ObjectUploadController {
 
     @PutMapping(value = "/**")
     public String putObject(@RequestBody File file) {
-        try {
-            HttpServletRequest servletRequest = ServletUtil.getRequest();
-            int channelId = Integer.parseInt(servletRequest.getHeader("x-channel-id"));
-            String sha256sum = servletRequest.getHeader("x-content-sha256sum");
-            String objectName = ObjectUtil.getObjectName();
-
-            String token = ServletUtil.getBearerToken();
-            if (token == null) {
-                return WebResult.failWithMsg("no token in request");
-            }
-
-            OssPayload ossPayload = JwtUtil.getOssPayload(token);
-            String action = ossPayload.getAction();
-            if (!"upload".equals(action)) {
-                return WebResult.failWithMsg("it's not upload token");
-            }
-
-            int channelId1 = ossPayload.getChannelId();
-            if (channelId != channelId1) {
-                return WebResult.failWithMsg("channel not match in token");
-            }
-
-            long userId1 = ossPayload.getUserId();
-            long userId = UserContext.getUser();
-            if (userId != userId1) {
-                return WebResult.failWithMsg("user not match in token");
-            }
-
-            boolean ret = channelValidateService.validate(file, channelId);
-            if (!ret) {
-                return WebResult.failWithMsg("the format or size of upload file error");
-            }
-
-            FileInputStream fis = new FileInputStream(file);
-            String sha256sum1 = DigestUtil.sha256sum(fis);
-            /*if (!sha256sum.equals(sha256sum1)) {
-                FileUtils.deleteQuietly(file);
-                return WebResult.failWithMsg("sha256sum not match");
-            }*/
-
-            String contentId = UUID.randomUUID().toString().replace("-", "");
-            File savedFile = fileStoreService.saveFile(file, contentId);
-
-            String originalFilename = file.getName();
-            String suffix = StringUtil.getSuffix(originalFilename);
-            ObjectProp objectProp = objectNameService.getObjectProp(channelId, suffix);
-            ObjectResult objectResult = putObjectService.putObject(objectProp, contentId, savedFile, originalFilename, sha256sum1);
-
-            UploadFileRet uploadFileRet = fileProcessor.process(objectResult, channelId);
-            if (uploadFileRet == null) {
-                String url = objectNameService.getObjectUrl(objectResult.getObjectName());
-                uploadFileRet = new UploadFileRet(objectResult.getObjectId(), url, false);
-            }
-
-            // TODO PutMessageConverter 中生成的文件需要显式删除
-            FileUtils.deleteQuietly(file);
-            return WebResult.success(uploadFileRet);
-        } catch (Exception e) {
-            FileUtils.deleteQuietly(file);
-            String errMsg = e.getMessage();
-            return WebResult.failWithMsg(errMsg);
-        }
+        return WebResult.failWithMsg("not implement");
     }
 
     @AuthUser
     @PostMapping(value = "/")
     public String postObject(MultipartFile file, String objectName, String sha256sum, Integer channelId) throws Exception {
+        /* permission check */
         String token = ServletUtil.getBearerToken();
         if (token == null) {
             return WebResult.failWithMsg("no token in request");
@@ -142,6 +75,7 @@ public class ObjectUploadController {
             return WebResult.failWithMsg("user not match in token");
         }
 
+        /* channel validate */
         String contentId = UUID.randomUUID().toString().replace("-", "");
         long size = file.getSize();
         File savedFile = fileStoreService.saveFile(file.getInputStream(), contentId, size);
@@ -151,21 +85,27 @@ public class ObjectUploadController {
             return WebResult.failWithMsg("the format or size of upload file error");
         }
 
+        /* store file */
         String sha256sum1 = DigestUtil.sha256sum(savedFile.getAbsolutePath());
-        String originalFilename = file.getOriginalFilename();
-        if (originalFilename == null) {
-            originalFilename = "";
+        String filename = file.getOriginalFilename();
+        if (filename == null) {
+            filename = "";
         }
 
-        String suffix = StringUtil.getSuffix(originalFilename);
-        ObjectProp objectProp = objectNameService.getObjectProp(channelId, suffix);
-        ObjectResult objectResult = putObjectService.putObject(objectProp, contentId, savedFile, originalFilename, sha256sum1);
-
+        ObjectProp objectProp = objectNameService.getObjectProp(channelId, filename);
+        ObjectResult objectResult = putObjectService.putObject(objectProp, contentId, savedFile, filename, sha256sum1);
         UploadFileRet uploadFileRet = fileProcessor.process(objectResult, channelId);
         if (uploadFileRet == null) {
-            String url = objectNameService.getObjectUrl(objectResult.getObjectName());
-            uploadFileRet = new UploadFileRet(objectResult.getObjectId(), url, false);
+            putObjectService.deleteObject(objectResult.getObjectId());
+            return WebResult.fail();
         }
         return WebResult.success(uploadFileRet);
     }
+
+    @AuthUser
+    @DeleteMapping(value = "/")
+    public String deleteObject(String objectId) {
+        putObjectService.deleteObject(objectId);
+        return WebResult.success();
+    }
 }

+ 1 - 1
dfs-store/src/main/java/cn/reghao/dfs/store/db/mapper/FileMetaMapper.java

@@ -33,7 +33,7 @@ public interface FileMetaMapper extends BaseMapper<FileMeta> {
     List<ObjectMeta> findObjectMetaByPage(Page page);
 
     /******************************************************************************************************************/
-    void updateSetAcl(@Param("objectId") String objectId, @Param("acl") int acl);
+    void updateSetAcl(@Param("objectId") String objectId, @Param("scope") int scope);
     void updateFilename(@Param("objectId") String objectId, @Param("filename") String filename);
     void updateParent(@Param("objectId") String objectId, @Param("pid") String pid);
     void updateSetDelete(String objectId);

+ 23 - 30
dfs-store/src/main/java/cn/reghao/dfs/store/db/repository/ObjectRepository.java

@@ -40,36 +40,6 @@ public class ObjectRepository {
         dataBlockMapper.saveAll(list);
     }
 
-    public void update(FileMeta fileMeta) {
-    }
-
-    @CacheEvict(cacheNames = "oss:store:objectMeta", key = "#fileMeta.objectName")
-    public void delete(FileMeta fileMeta) {
-    }
-
-    @Cacheable(cacheNames = "oss:store:fileMeta", key = "#objectName", unless = "#result == null")
-    public FileMeta getByObjectName(String objectName) {
-        log.info("cache miss");
-        return fileMetaMapper.findByObjectName(objectName);
-    }
-
-    public FileMeta getByObjectId(String objectId) {
-        log.info("cache miss");
-        return fileMetaMapper.findByObjectId(objectId);
-    }
-
-    @Cacheable(cacheNames = "oss:store:fileMeta", key = "#sha256sum", unless = "#result == null")
-    public FileMeta getBySha256sum(String sha256sum) {
-        return fileMetaMapper.findBySha256sum(sha256sum);
-    }
-
-    @Cacheable(cacheNames = "oss:store:objectMeta", key = "#objectName", unless = "#result == null")
-    public ObjectMeta getObjectMeta(String objectName) {
-        log.info("cache miss");
-        ObjectMeta objectMeta = fileMetaMapper.findObjectMeta(objectName);
-        return objectMeta;
-    }
-
     @CacheEvict(cacheNames = "oss:store:objectMeta", key = "#objectName")
     @Transactional(rollbackFor = Exception.class)
     public void deleteObject(String objectName) {
@@ -109,4 +79,27 @@ public class ObjectRepository {
     public void deleteByObjectIds(List<String> objectIds) {
         objectIds.forEach(this::deleteByObjectId);
     }
+
+    @Cacheable(cacheNames = "oss:store:fileMeta", key = "#objectName", unless = "#result == null")
+    public FileMeta getByObjectName(String objectName) {
+        log.info("cache miss");
+        return fileMetaMapper.findByObjectName(objectName);
+    }
+
+    public FileMeta getByObjectId(String objectId) {
+        log.info("cache miss");
+        return fileMetaMapper.findByObjectId(objectId);
+    }
+
+    @Cacheable(cacheNames = "oss:store:fileMeta", key = "#sha256sum", unless = "#result == null")
+    public FileMeta getBySha256sum(String sha256sum) {
+        return fileMetaMapper.findBySha256sum(sha256sum);
+    }
+
+    @Cacheable(cacheNames = "oss:store:objectMeta", key = "#objectName", unless = "#result == null")
+    public ObjectMeta getObjectMeta(String objectName) {
+        log.info("cache miss");
+        ObjectMeta objectMeta = fileMetaMapper.findObjectMeta(objectName);
+        return objectMeta;
+    }
 }

+ 4 - 4
dfs-store/src/main/java/cn/reghao/dfs/store/inerceptor/AccessLogInterceptor.java

@@ -57,13 +57,13 @@ public class AccessLogInterceptor implements HandlerInterceptor {
                 return true;
             }
 
-            int acl = fileMeta.getAcl();
-            if (acl == ObjectScope.PRIVATE.getCode()) {
+            int scope = fileMeta.getScope();
+            if (scope == ObjectScope.PRIVATE.getCode()) {
                 response.setStatus(HttpServletResponse.SC_FORBIDDEN);
                 return false;
-            } else if (acl == ObjectScope.PUBLIC.getCode()) {
+            } else if (scope == ObjectScope.PUBLIC.getCode()) {
                 return true;
-            } else if (acl == ObjectScope.FRIEND.getCode()) {
+            } else if (scope == ObjectScope.FRIEND.getCode()) {
                 return false;
             }
         } else if (method.equals("PUT") || method.equals("POST")) {

+ 7 - 7
dfs-store/src/main/java/cn/reghao/dfs/store/model/po/FileMeta.java

@@ -25,12 +25,12 @@ public class FileMeta extends BaseObject<Integer> {
     private Long size;
     private Integer fileType;
     private String contentType;
-    private int acl;
+    private int scope;
     private Long uploadBy;
     private Boolean diskFile;
 
     // 目录对象
-    public FileMeta(String objectName, String objectId, String filename, String pid, int acl) {
+    public FileMeta(String objectName, String objectId, String filename, String pid, int scope) {
         this.objectName = objectName;
         this.objectId = objectId;
         this.contentId = "0";
@@ -42,11 +42,11 @@ public class FileMeta extends BaseObject<Integer> {
         this.pid = pid;
         this.uploadBy = UserContext.getUser();
         this.diskFile = false;
-        this.acl = acl;
+        this.scope = scope;
     }
 
     public FileMeta(String objectName, String objectId, String contentId, String filename, long size,
-                    int fileType, String contentType, String sha256sum, String pid, boolean diskFile, int acl) {
+                    int fileType, String contentType, String sha256sum, String pid, boolean diskFile, int scope) {
         this.objectName = objectName;
         this.objectId = objectId;
         this.contentId = contentId;
@@ -58,10 +58,10 @@ public class FileMeta extends BaseObject<Integer> {
         this.pid = pid;
         this.uploadBy = UserContext.getUser();
         this.diskFile = diskFile;
-        this.acl = acl;
+        this.scope = scope;
     }
 
-    public FileMeta(String objectName, String objectId, String filename, FileMeta fileMeta, boolean diskFile, int acl) {
+    public FileMeta(String objectName, String objectId, String filename, FileMeta fileMeta, boolean diskFile, int scope) {
         this.objectName = objectName;
         this.objectId = objectId;
         this.contentId = fileMeta.getContentId();
@@ -73,6 +73,6 @@ public class FileMeta extends BaseObject<Integer> {
         this.pid = fileMeta.getPid();
         this.uploadBy = UserContext.getUser();
         this.diskFile = diskFile;
-        this.acl = acl;
+        this.scope = scope;
     }
 }

+ 1 - 1
dfs-store/src/main/java/cn/reghao/dfs/store/model/vo/ObjectProp.java

@@ -12,6 +12,6 @@ import lombok.Getter;
 public class ObjectProp {
     private String objectName;
     private boolean diskFile;
-    private int acl;
+    private int scope;
     private String pid;
 }

+ 2 - 2
dfs-store/src/main/java/cn/reghao/dfs/store/rpc/ObjectServiceImpl.java

@@ -36,12 +36,12 @@ public class ObjectServiceImpl implements ObjectService {
     @Override
     public void putObjectPrefix(ObjectPrefix objectPrefix) {
         String prefix = objectPrefix.getPrefix();
-        int acl = objectPrefix.getAcl();
+        int scope = objectPrefix.getScope();
         FileMeta fileMeta = fileMetaMapper.findByObjectName(prefix);
         if (fileMeta != null) {
             return;
         }
-        objectNameService.createParentDirs(prefix, acl);
+        objectNameService.createParentDirs(prefix, scope);
     }
 
     @Override

+ 2 - 2
dfs-store/src/main/java/cn/reghao/dfs/store/rpc/PermissionServiceImpl.java

@@ -36,12 +36,12 @@ public class PermissionServiceImpl implements PermissionService {
     }
 
     @Override
-    public void setDirPermission(String prefix, int acl) {
+    public void setDirPermission(String prefix, int scope) {
     }
 
     @Override
     public void getDirPermission(String prefix) {
-        for (ObjectScope acl : ObjectScope.values()) {
+        for (ObjectScope scope : ObjectScope.values()) {
         }
     }
 

+ 2 - 2
dfs-store/src/main/java/cn/reghao/dfs/store/service/ObjectMultipartUploadService.java

@@ -83,7 +83,7 @@ public class ObjectMultipartUploadService {
             putObjectService.copyObject(objectProp, filename, fileMeta);
 
             String url = String.format("https://%s/%s", domain, objectProp);
-            return new UploadFileRet(sha256sum, url, false);
+            return new UploadFileRet(sha256sum, url);
         }
 
         Set<Long> set = map.computeIfAbsent(sha256sum, k -> new HashSet<>());
@@ -124,7 +124,7 @@ public class ObjectMultipartUploadService {
             map.remove(sha256sum);
             pathMap.remove(sha256sum);
             String url = String.format("https://%s/%s", domain, objectProp);
-            return new UploadFileRet(sha256sum, url, false);
+            return new UploadFileRet(sha256sum, url);
         }
     }
 }

+ 11 - 9
dfs-store/src/main/java/cn/reghao/dfs/store/service/ObjectNameService.java

@@ -4,6 +4,7 @@ import cn.reghao.dfs.store.config.OssProperties;
 import cn.reghao.dfs.store.db.repository.ObjectRepository;
 import cn.reghao.dfs.store.model.po.FileMeta;
 import cn.reghao.dfs.store.model.vo.ObjectProp;
+import cn.reghao.dfs.store.util.StringUtil;
 import cn.reghao.oss.api.constant.ObjectScope;
 import cn.reghao.oss.api.constant.UploadChannel;
 import org.springframework.stereotype.Service;
@@ -34,7 +35,8 @@ public class ObjectNameService {
         return url.replace(String.format("//%s/", domain), "");
     }
 
-    public ObjectProp getObjectProp(int channelId, String suffix) throws Exception {
+    public ObjectProp getObjectProp(int channelId, String filename) throws Exception {
+        String suffix = StringUtil.getSuffix(filename);
         UploadChannel channel = UploadChannel.getUploadChannel(channelId);
         if (channel == null) {
             throw new Exception("channelId 不合法");
@@ -43,13 +45,13 @@ public class ObjectNameService {
         String objectPrefix = channel.getPrefix();
         String objectName = objectPrefix + UUID.randomUUID().toString().replace("-", "") + suffix;
         boolean diskFile;
-        int acl;
+        int scope;
         if (channelId == UploadChannel.disk.getCode()) {
             diskFile = true;
-            acl = ObjectScope.PRIVATE.getCode();
+            scope = ObjectScope.PRIVATE.getCode();
         } else {
             diskFile = false;
-            acl = ObjectScope.PUBLIC.getCode();
+            scope = ObjectScope.PUBLIC.getCode();
         }
 
         FileMeta fileMeta = objectRepository.getByObjectName(objectPrefix);
@@ -59,7 +61,7 @@ public class ObjectNameService {
         }
 
         String pid = fileMeta.getObjectId();
-        return new ObjectProp(objectName, diskFile, acl, pid);
+        return new ObjectProp(objectName, diskFile, scope, pid);
     }
 
     public ObjectProp getObjectProp(String originalObjectName, String suffix) {
@@ -68,12 +70,12 @@ public class ObjectNameService {
         UploadChannel channel = UploadChannel.getUploadChannel(prefix);
         FileMeta fileMeta = objectRepository.getByObjectName(originalObjectName);
         boolean diskFile = fileMeta.getDiskFile();
-        int acl = fileMeta.getAcl();
+        int scope = fileMeta.getScope();
         String pid = fileMeta.getPid();
 
         String objectPrefix = channel.getPrefix();
         String objectName = objectPrefix + UUID.randomUUID().toString().replace("-", "") + suffix;
-        return new ObjectProp(objectName, diskFile, acl, pid);
+        return new ObjectProp(objectName, diskFile, scope, pid);
     }
 
     public String getObjectNameFromOriginal(String originalObjectName, String suffix) {
@@ -83,7 +85,7 @@ public class ObjectNameService {
         return prefix + id + suffix;
     }
 
-    public void createParentDirs(String objectName, int acl) {
+    public void createParentDirs(String objectName, int scope) {
         List<String> list = getSortedParent(objectName);
         for (int i = 0; i < list.size(); i++) {
             String parentName = list.get(i);
@@ -98,7 +100,7 @@ public class ObjectNameService {
                 String objectId = UUID.randomUUID().toString().replace("-", "");
                 String[] names = parentName.split("/");
                 String filename = names[names.length-1];
-                objectRepository.saveFileMeta(new FileMeta(parentName, objectId, filename, pid, acl));
+                objectRepository.saveFileMeta(new FileMeta(parentName, objectId, filename, pid, scope));
             }
         }
     }

+ 9 - 32
dfs-store/src/main/java/cn/reghao/dfs/store/service/PutObjectService.java

@@ -7,7 +7,6 @@ import cn.reghao.dfs.store.model.vo.ObjectProp;
 import cn.reghao.dfs.store.model.vo.ObjectResult;
 import cn.reghao.dfs.store.util.FileType;
 import cn.reghao.dfs.store.util.StringUtil;
-import cn.reghao.jutil.jdk.security.DigestUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
 import org.springframework.stereotype.Service;
@@ -24,13 +23,10 @@ import java.util.UUID;
 @Service
 public class PutObjectService {
     private final ObjectRepository objectRepository;
-    private final FileStoreService fileStoreService;
     private final ObjectNameService objectNameService;
 
-    public PutObjectService(ObjectRepository objectRepository, FileStoreService fileStoreService,
-                            ObjectNameService objectNameService) {
+    public PutObjectService(ObjectRepository objectRepository, ObjectNameService objectNameService) {
         this.objectRepository = objectRepository;
-        this.fileStoreService = fileStoreService;
         this.objectNameService = objectNameService;
     }
 
@@ -49,9 +45,9 @@ public class PutObjectService {
             int fileType = FileType.getFileType(contentType);
 
             boolean diskFile = objectProp.isDiskFile();
-            int acl = objectProp.getAcl();
+            int scope = objectProp.getScope();
             fileMeta = new FileMeta(objectName, objectId, contentId, originalFilename, size,
-                    fileType, contentType, sha256sum, pid, diskFile, acl);
+                    fileType, contentType, sha256sum, pid, diskFile, scope);
             String blockId = UUID.randomUUID().toString();
             List<DataBlock> list = List.of(new DataBlock(contentId, 0, blockId, savedPath, size));
             objectRepository.saveObject(fileMeta, list);
@@ -60,25 +56,6 @@ public class PutObjectService {
     }
 
     public void putObject(String objectName, byte[] bytes) {
-        try {
-            String sha256sum = DigestUtil.sha256sum(bytes);
-            FileMeta fileMeta = objectRepository.getBySha256sum(sha256sum);
-            if (fileMeta != null) {
-                //copyObject(objectName, objectName, fileMeta);
-            } else {
-                String pid = "";
-                String contentId = "";
-                File savedFile = fileStoreService.saveFile(bytes, contentId);
-                String filename = "";
-
-                String objectId = "";
-                String savedPath = savedFile.getAbsolutePath();
-                String contentType = FileType.getMediaType(savedPath);
-                int fileType = FileType.getFileType(contentType);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
     }
 
     public ObjectResult copyObject(ObjectProp objectProp, String filename, FileMeta fileMeta) {
@@ -88,8 +65,8 @@ public class PutObjectService {
         String objectName = objectProp.getObjectName();
         String objectId = UUID.randomUUID().toString().replace("-", "");
         boolean diskFile = objectProp.isDiskFile();
-        int acl = objectProp.getAcl();
-        FileMeta fileMeta1 = new FileMeta(objectName, objectId, filename, fileMeta, diskFile, acl);
+        int scope = objectProp.getScope();
+        FileMeta fileMeta1 = new FileMeta(objectName, objectId, filename, fileMeta, diskFile, scope);
         objectRepository.saveFileMeta(fileMeta1);
         return new ObjectResult(objectName, objectId, fileType, savedPath, dupObjectId);
     }
@@ -102,15 +79,15 @@ public class PutObjectService {
         String filename = fileMeta.getFilename();
         String savedPath = "";
         boolean diskFile = fileMeta.getDiskFile();
-        int acl = fileMeta.getAcl();
+        int scope = fileMeta.getScope();
         String toObjectName = objectNameService.getObjectNameFromOriginal(fromObjectName, suffix);
         String toObjectId = UUID.randomUUID().toString().replace("-", "");
-        FileMeta fileMeta1 = new FileMeta(toObjectName, toObjectId, filename, fileMeta, diskFile, acl);
+        FileMeta fileMeta1 = new FileMeta(toObjectName, toObjectId, filename, fileMeta, diskFile, scope);
         objectRepository.saveFileMeta(fileMeta1);
         return new ObjectResult(toObjectName, toObjectId, fileType, savedPath);
     }
 
-    public void deleteObject(String objectName) {
-        objectRepository.deleteObject(objectName);
+    public void deleteObject(String objectId) {
+        //objectRepository.deleteByObjectId(objectId);
     }
 }

+ 3 - 3
dfs-store/src/main/java/cn/reghao/dfs/store/task/AudioFileProcessor.java

@@ -58,7 +58,7 @@ public class AudioFileProcessor {
             String audioCodec = audioFile.getCodec();
             AudioFile audioFile1 = new AudioFile(audioFileId, objectId1, audioCodec, url1);
             audioRepository.saveAudioFile(audioFile1);
-            return new UploadFileRet(objectId1, url1, true);
+            return new UploadFileRet(objectId1, url1);
         }
 
         String absolutePath = objectResult.getAbsolutePath();
@@ -81,7 +81,7 @@ public class AudioFileProcessor {
         String url1 = objectNameService.getObjectUrl(objectResult1.getObjectName());
         AudioFile audioFile = new AudioFile(audioFileId, objectId1, audioCodec, url1);
         audioRepository.saveAudioFile(audioFile);
-        return new UploadFileRet(objectId1, url1, true);
+        return new UploadFileRet(objectId1, url1);
     }
 
     private UploadFileRet getConvertedAudioFile(String audioFileId, File file, String originalObjectName, String suffix) {
@@ -107,7 +107,7 @@ public class AudioFileProcessor {
             String codec = "aac";
             AudioFile audioFile = new AudioFile(audioFileId, objectId, codec, url);
             audioRepository.saveAudioFile(audioFile);
-            return new UploadFileRet(objectId, url, true);
+            return new UploadFileRet(objectId, url);
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 1 - 1
dfs-store/src/main/java/cn/reghao/dfs/store/task/DiskFileProcessor.java

@@ -21,6 +21,6 @@ public class DiskFileProcessor {
         String objectName = objectResult.getObjectName();
         String objectId = objectResult.getObjectId();
         String url = objectNameService.getObjectUrl(objectName);
-        return new UploadFileRet(objectId, url, false);
+        return new UploadFileRet(objectId, url);
     }
 }

+ 4 - 4
dfs-store/src/main/java/cn/reghao/dfs/store/task/ImageFileProcessor.java

@@ -67,7 +67,7 @@ public class ImageFileProcessor {
             ImageUrl imageUrl1 = new ImageUrl(objectId, format, objectId, url, width, height);
 
             imageRepository.saveImageFile(imageFile1, List.of(imageUrl1));
-            return new UploadFileRet(objectId, url, true);
+            return new UploadFileRet(objectId, url);
         }
 
         String absolutePath = objectResult.getAbsolutePath();
@@ -82,7 +82,7 @@ public class ImageFileProcessor {
                 ImageFile imageFile = new ImageFile(objectId, width, height);
                 ImageUrl imageUrl = new ImageUrl(objectId, format, objectId, url, width, height);
                 imageRepository.saveImageFile(imageFile, List.of(imageUrl));
-                return new UploadFileRet(objectId, url, true);
+                return new UploadFileRet(objectId, url);
             } else {
                 log.info("不支持 {} 格式的文件", format);
             }
@@ -124,7 +124,7 @@ public class ImageFileProcessor {
             list.add(imageUrl1);
 
             imageRepository.saveImageFile(imageFile1, list);
-            return new UploadFileRet(objectId, url, true);
+            return new UploadFileRet(objectId, url);
         }
 
         String absolutePath = objectResult.getAbsolutePath();
@@ -148,7 +148,7 @@ public class ImageFileProcessor {
                 }
 
                 imageRepository.saveImageFile(imageFile, imageUrls);
-                return new UploadFileRet(objectId, url, true);
+                return new UploadFileRet(objectId, url);
             } else {
                 log.info("不支持 {} 格式的文件", format);
             }

+ 2 - 2
dfs-store/src/main/java/cn/reghao/dfs/store/task/VideoFileProcessor.java

@@ -82,7 +82,7 @@ public class VideoFileProcessor {
                     urlType, url, bitRate, quality, width, height, order);
 
             videoRepository.saveVideoFile(videoFile1, videoUrl1);
-            return new UploadFileRet(videoFileId, url, true);
+            return new UploadFileRet(videoFileId, url);
         }
 
         String absolutePath = objectResult.getAbsolutePath();
@@ -128,7 +128,7 @@ public class VideoFileProcessor {
         VideoUrl videoUrl  =
                 new VideoUrl(videoFileId, videoFileId, videoCodec, audioCodec, urlType, originalUrl, bitRate, mediaResolution);
         videoRepository.saveVideoFile(videoFile, videoUrl);
-        return new UploadFileRet(videoFileId, originalUrl, true);
+        return new UploadFileRet(videoFileId, originalUrl);
 
         //log.info("添加视频格式转码任务");
         //threadPool.submit(new ConvertTask());

+ 8 - 8
dfs-store/src/main/resources/mapper/FileMetaMapper.xml

@@ -4,16 +4,16 @@
 <mapper namespace="cn.reghao.dfs.store.db.mapper.FileMetaMapper">
     <insert id="save" useGeneratedKeys="true" keyProperty="id">
         insert into file_meta
-        (`id`,`deleted`,`create_time`,`update_time`,`object_name`,`object_id`,`content_id`,`pid`,`filename`,`size`,`file_type`,`content_type`,`sha256sum`,`upload_by`,`disk_file`,`acl`)
+        (`id`,`deleted`,`create_time`,`update_time`,`object_name`,`object_id`,`content_id`,`pid`,`filename`,`size`,`file_type`,`content_type`,`sha256sum`,`upload_by`,`disk_file`,`scope`)
         values
-        (#{id},#{deleted},#{createTime},#{updateTime},#{objectName},#{objectId},#{contentId},#{pid},#{filename},#{size},#{fileType},#{contentType},#{sha256sum},#{uploadBy},#{diskFile},#{acl})
+        (#{id},#{deleted},#{createTime},#{updateTime},#{objectName},#{objectId},#{contentId},#{pid},#{filename},#{size},#{fileType},#{contentType},#{sha256sum},#{uploadBy},#{diskFile},#{scope})
     </insert>
     <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
         insert into file_meta
-        (`id`,`deleted`,`create_time`,`update_time`,`object_name`,`object_id`,`content_id`,`pid`,`filename`,`size`,`file_type`,`content_type`,`sha256sum`,`upload_by`,`disk_file`,`acl`)
+        (`id`,`deleted`,`create_time`,`update_time`,`object_name`,`object_id`,`content_id`,`pid`,`filename`,`size`,`file_type`,`content_type`,`sha256sum`,`upload_by`,`disk_file`,`scope`)
         values
         <foreach collection="list" item="item" index="index" separator=",">
-            (#{item.id},#{item.deleted},#{item.createTime},#{item.updateTime},#{item.objectName},#{item.objectId},#{item.contentId},#{item.pid},#{item.filename},#{item.size},#{item.fileType},#{item.contentType},#{item.sha256sum},#{item.uploadBy},#{item.diskFile},#{item.acl})
+            (#{item.id},#{item.deleted},#{item.createTime},#{item.updateTime},#{item.objectName},#{item.objectId},#{item.contentId},#{item.pid},#{item.filename},#{item.size},#{item.fileType},#{item.contentType},#{item.sha256sum},#{item.uploadBy},#{item.diskFile},#{item.scope})
         </foreach>
     </insert>
 
@@ -27,7 +27,7 @@
     </update>
     <update id="updateSetAcl">
         update file_meta
-        set update_time=now() and acl=#{acl}
+        set update_time=now() and scope=#{scope}
         where object_id=#{objectId}
     </update>
     <update id="update">
@@ -104,7 +104,7 @@
         where content_id=#{contentId}
     </select>
     <select id="findObjectMeta" resultType="cn.reghao.oss.api.dto.ObjectMeta">
-        select file_meta.size,file_meta.content_type,file_meta.object_name,file_meta.object_id,file_meta.acl as scope,file_meta.upload_by,
+        select file_meta.size,file_meta.content_type,file_meta.object_name,file_meta.object_id,file_meta.scope as scope,file_meta.upload_by,
         data_block.absolute_path
         from file_meta
         inner join data_block
@@ -112,7 +112,7 @@
         and file_meta.object_name=#{objectName}
     </select>
     <select id="findObjectMetaByPage" resultType="cn.reghao.oss.api.dto.ObjectMeta">
-        select file_meta.size,file_meta.content_type,file_meta.object_name,file_meta.object_id,file_meta.acl as scope,file_meta.upload_by,
+        select file_meta.size,file_meta.content_type,file_meta.object_name,file_meta.object_id,file_meta.scope as scope,file_meta.upload_by,
         data_block.absolute_path
         from file_meta
         inner join data_block
@@ -217,7 +217,7 @@
         where file_type==1000
     </select>
     <select id="findAclByObjectPrefix" resultType="java.lang.Integer">
-        select acl
+        select scope
         from file_meta
         where object_prefix=#{objectPrefix}
     </select>

+ 1 - 1
oss-api/src/main/java/cn/reghao/oss/api/dto/ObjectPrefix.java

@@ -17,5 +17,5 @@ public class ObjectPrefix implements Serializable {
     @NotBlank
     private String prefix;
     @NotNull
-    private Integer acl;
+    private Integer scope;
 }

+ 1 - 4
oss-api/src/main/java/cn/reghao/oss/api/rest/UploadFileRet.java

@@ -15,19 +15,16 @@ public class UploadFileRet implements Serializable {
     private final String uploadId;
     private final String url;
     private final boolean merged;
-    private final boolean processed;
 
     public UploadFileRet(String uploadId) {
         this.uploadId = uploadId;
         this.url = null;
         this.merged = false;
-        this.processed = false;
     }
 
-    public UploadFileRet(String uploadId, String url, boolean processed) {
+    public UploadFileRet(String uploadId, String url) {
         this.uploadId = uploadId;
         this.url = url;
         this.merged = true;
-        this.processed = processed;
     }
 }