diff --git a/src/main/java/com/jmal/clouddisk/controller/rest/VideoController.java b/src/main/java/com/jmal/clouddisk/controller/rest/VideoController.java index b4b31fab..cf21a963 100644 --- a/src/main/java/com/jmal/clouddisk/controller/rest/VideoController.java +++ b/src/main/java/com/jmal/clouddisk/controller/rest/VideoController.java @@ -3,7 +3,6 @@ import com.jmal.clouddisk.config.FileProperties; import com.jmal.clouddisk.service.IShareService; import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import org.springframework.core.io.UrlResource; import org.springframework.http.HttpHeaders; @@ -26,34 +25,34 @@ public class VideoController { private final IShareService shareService; - @GetMapping("/video/hls/{username}/{fileMd5}.m3u8") - public ResponseEntity m3u8(@PathVariable String username, @PathVariable String fileMd5) throws IOException { - Path m3u8Path = Paths.get(fileProperties.getRootDir(), fileProperties.getChunkFileDir(), username, fileProperties.getVideoTranscodeCache(), fileMd5, fileMd5 + ".m3u8"); + @GetMapping("/video/hls/{username}/{fileId}.m3u8") + public ResponseEntity m3u8(@PathVariable String username, @PathVariable String fileId) throws IOException { + Path m3u8Path = Paths.get(fileProperties.getRootDir(), fileProperties.getChunkFileDir(), username, fileProperties.getVideoTranscodeCache(), fileId, fileId + ".m3u8"); UrlResource videoResource = new UrlResource(m3u8Path.toUri()); return ResponseEntity.ok() .header(HttpHeaders.CONTENT_TYPE, "application/vnd.apple.mpegurl") .body(videoResource); } - @GetMapping("/video/hls/{username}/{fileMd5}-{index}.ts") - public ResponseEntity ts(@PathVariable String username, @PathVariable String fileMd5, @PathVariable String index) throws IOException { - Path m3u8Path = Paths.get(fileProperties.getRootDir(), fileProperties.getChunkFileDir(), username, fileProperties.getVideoTranscodeCache(), fileMd5, fileMd5 + "-" + index + ".ts"); + @GetMapping("/video/hls/{username}/{fileId}-{index}.ts") + public ResponseEntity ts(@PathVariable String username, @PathVariable String fileId, @PathVariable String index) throws IOException { + Path m3u8Path = Paths.get(fileProperties.getRootDir(), fileProperties.getChunkFileDir(), username, fileProperties.getVideoTranscodeCache(), fileId, fileId + "-" + index + ".ts"); UrlResource videoResource = new UrlResource(m3u8Path.toUri()); return ResponseEntity.ok() .header(HttpHeaders.CONTENT_TYPE, "application/vnd.apple.mpegurl") .body(videoResource); } - @GetMapping("/public/video/hls/{username}/{fileMd5}.m3u8") - public ResponseEntity publicM3u8(@PathVariable String username, @PathVariable String fileMd5, HttpServletRequest request) throws IOException { - shareService.validShare(request); - return m3u8(username, fileMd5); + @GetMapping("/public/video/hls/{shareId}/{shareToken}/{username}/{fileId}.m3u8") + public ResponseEntity publicM3u8(@PathVariable String username, @PathVariable String fileId, @PathVariable String shareId, @PathVariable String shareToken) throws IOException { + shareService.validShare(shareToken, shareId); + return m3u8(username, fileId); } - @GetMapping("/public/video/hls/{username}/{fileMd5}-{index}.ts") - public ResponseEntity publicTs(@PathVariable String username, @PathVariable String fileMd5, @PathVariable String index, HttpServletRequest request) throws IOException { - shareService.validShare(request); - return ts(username, fileMd5, index); + @GetMapping("/public/video/hls/{shareId}/{shareToken}/{username}/{fileId}-{index}.ts") + public ResponseEntity publicTs(@PathVariable String username, @PathVariable String fileId, @PathVariable String index, @PathVariable String shareId, @PathVariable String shareToken) throws IOException { + shareService.validShare(shareToken, shareId); + return ts(username, fileId, index); } }