소스 검색

适配最新的core-fss修改,增加fss内置端点访问测试代码

luoshi 11 달 전
부모
커밋
c1263a8779

+ 0 - 8
api-demo/src/main/java/com/qmth/demo/api/controller/AiController.java

@@ -9,10 +9,8 @@ import com.qmth.boot.core.retrofit.utils.SignatureInfo;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
-import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -44,10 +42,4 @@ public class AiController {
         return aiService.autoScore(request, SignatureInfo.secret(accessKey, ""));
     }
 
-    @RequestMapping("/auto_score_image")
-    public Object autoScore(@RequestParam String accessKey, AutoScoreRequest request, @RequestParam MultipartFile image)
-            throws IOException {
-        return aiService.autoScore(request, image.getBytes(), SignatureInfo.secret(accessKey, ""));
-    }
-
 }

+ 18 - 9
api-demo/src/main/java/com/qmth/demo/api/controller/FileController.java

@@ -2,7 +2,7 @@ package com.qmth.demo.api.controller;
 
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
-import com.qmth.boot.core.fss.store.FileStore;
+import com.qmth.boot.core.fss.service.FileService;
 import com.qmth.boot.core.retrofit.utils.UploadFile;
 import com.qmth.boot.tools.models.ByteArray;
 import com.qmth.demo.api.client.FileTestClient;
@@ -14,37 +14,46 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
+import java.time.Duration;
 
 @RestController
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/file")
 @Aac(auth = false)
 public class FileController {
 
-    //    @Resource
-    //    FileService fileService;
-
     @Resource
-    FileStore fileStore;
+    FileService fileService;
+
+    //@Resource
+    //FileStore fileStore;
 
     @Resource
     FileTestClient fileTestClient;
 
+    @RequestMapping("/server_url")
+    public Object getServerUrl(@RequestParam String bucket, @RequestParam String path,
+            @RequestParam(required = false) Long expireSecond) {
+        //return fileService.getFileStore("public").getServer();
+        return fileService.getFileStore(bucket)
+                .getServerUrl(path, expireSecond != null ? Duration.ofSeconds(expireSecond) : null);
+    }
+
     @RequestMapping("/server")
     public Object server() {
         //return fileService.getFileStore("public").getServer();
-        return fileStore.getServer();
+        return fileService.getFileStore("").getServer();
     }
 
     @RequestMapping("/exist")
-    public boolean exist(@RequestParam String path) {
+    public boolean exist(@RequestParam String path) throws IOException {
         //return fileService.getFileStore("public").exist(path);
-        return fileStore.exist(path);
+        return fileService.getFileStore("").exist(path);
     }
 
     @RequestMapping("/upload")
     public Object upload(@RequestParam String path, @RequestParam String md5, @RequestParam MultipartFile file)
             throws Exception {
-        fileStore.write(path, file.getInputStream(), md5);
+        fileService.getFileStore("").write(path, file.getInputStream(), md5);
         return path;
     }
 

+ 6 - 4
api-demo/src/main/resources/application.properties

@@ -25,10 +25,12 @@ com.qmth.cache.expire-after-write=30m
 
 com.qmth.redis.host=127.0.0.1
 
-##com.qmth.fss.public.config=/Users/luoshi/test
-##com.qmth.fss.public.server=https://server.com
-com.qmth.fss.config=/Users/luoshi/test
-com.qmth.fss.server=https://server.com
+com.qmth.fss.public.config=/Users/luoshi/test
+com.qmth.fss.public.server=/api/file
+com.qmth.fss.private.config=/Users/luoshi/test
+com.qmth.fss.private.server=/fss
+##com.qmth.fss.config=/Users/luoshi/test
+##com.qmth.fss.server=/fss
 
 ##solar online
 #com.qmth.solar.server=http://localhost:8090