|
@@ -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;
|
|
|
}
|
|
|
|