浏览代码

更新注释

reghao 3 年之前
父节点
当前提交
f7b45d4065

+ 2 - 5
README.md

@@ -1,9 +1,6 @@
-# dfs
-- file:8002
+# dfs-store
+分布式存储系统
 
 ## 依赖的第三方服务
 - mysql
 - zookeeper
-
-## 域名
-- file.reghao.cn

+ 1 - 1
src/main/java/cn/reghao/dfs/store/controller/FileDownloadController.java

@@ -15,7 +15,7 @@ import java.io.*;
  * @date 2020-03-11 16:10:16
  */
 @Slf4j
-@Api(tags = "文件服务下载接口")
+@Api(tags = "文件下载接口")
 @RestController
 @RequestMapping("/api/file/dl")
 public class FileDownloadController {

+ 1 - 1
src/main/java/cn/reghao/dfs/store/controller/FileUploadController.java

@@ -17,7 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
  * @author reghao
  * @date 2020-03-11 16:10:16
  */
-@Api(tags = "文件服务上传接口")
+@Api(tags = "文件上传接口")
 @RestController
 @RequestMapping("/api/file/upload")
 public class FileUploadController {

+ 3 - 22
src/main/java/cn/reghao/dfs/store/controller/ImageFileController.java

@@ -3,6 +3,7 @@ package cn.reghao.dfs.store.controller;
 import cn.reghao.dfs.store.model.dto.PathUrl;
 import cn.reghao.dfs.store.service.FileUrlService;
 import cn.reghao.dfs.store.service.media.ImageFileService;
+import io.swagger.annotations.Api;
 import org.springframework.core.io.InputStreamResource;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
@@ -10,14 +11,13 @@ import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.HttpServletResponse;
 import java.io.*;
-import java.nio.charset.StandardCharsets;
 
 /**
  * @author reghao
  * @date 2022-04-24 16:13:10
  */
+@Api(tags = "图片文件访问接口")
 @RestController
 @RequestMapping
 public class ImageFileController {
@@ -29,26 +29,6 @@ public class ImageFileController {
         this.imageFileService = imageFileService;
     }
 
-    @GetMapping("/image2/{filename}")
-    @Deprecated
-    public ResponseEntity<InputStreamResource> image2(@PathVariable("filename") String filename) throws Exception {
-        String uploadId = filename.split("\\.")[0];
-        PathUrl pathUrl = fileUrlService.getPathUrl(uploadId);
-        if (pathUrl == null) {
-            return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
-        }
-
-        String absolutePath = pathUrl.getAbsolutePath();
-        FileInputStream fis = new FileInputStream(absolutePath);
-        InputStreamResource inputStreamResource = new InputStreamResource(fis);
-
-        HttpHeaders httpHeaders = new HttpHeaders();
-        httpHeaders.set("Pragma", "No-cache");
-        httpHeaders.set("Cache-Control", "no-cache");
-        return ResponseEntity.status(HttpStatus.OK).headers(httpHeaders).contentType(MediaType.IMAGE_JPEG)
-                .body(inputStreamResource);
-    }
-
     @GetMapping("/image/{filename:.+}")
     public ResponseEntity<InputStreamResource> image(@PathVariable("filename") String filename) throws Exception {
         String[] strs = filename.split("@");
@@ -66,6 +46,7 @@ public class ImageFileController {
             String[] params = strs[1].split("_");
             int width = Integer.parseInt(params[0].replace("w", ""));
             int height = Integer.parseInt(params[1].replace("h", ""));
+            // TODO 在 response header 中会有 Content-Disposition  inline;filename=f.txt 浏览器标签栏显示的名字是 f.txt
             inputStream = imageFileService.getImageStream(absolutePath, width, height);
         }
 

+ 2 - 0
src/main/java/cn/reghao/dfs/store/controller/VideoFileController.java

@@ -7,6 +7,7 @@ import cn.reghao.dfs.api.dto.FileAccess;
 import cn.reghao.dfs.store.service.FileUrlService;
 import cn.reghao.jutil.jdk.security.crypto.AesEncrypt;
 import cn.reghao.jutil.web.ServletUtil;
+import io.swagger.annotations.Api;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
@@ -21,6 +22,7 @@ import java.util.Arrays;
  * @author reghao
  * @date 2022-04-24 16:13:10
  */
+@Api(tags = "视频文件访问接口")
 @RestController
 @RequestMapping("/video")
 public class VideoFileController {