diff --git a/src/main/java/com/yutou/tools/ToolsApplication.java b/src/main/java/com/yutou/tools/ToolsApplication.java index 5034f70..9841d68 100644 --- a/src/main/java/com/yutou/tools/ToolsApplication.java +++ b/src/main/java/com/yutou/tools/ToolsApplication.java @@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class ToolsApplication { - public static final String version="1.1.4"; + public static final String version="1.1.5"; public static void main(String[] args) { System.out.println("当前版本号:" + version); diff --git a/src/main/java/com/yutou/tools/other/tools.java b/src/main/java/com/yutou/tools/other/tools.java index a51287a..923d241 100644 --- a/src/main/java/com/yutou/tools/other/tools.java +++ b/src/main/java/com/yutou/tools/other/tools.java @@ -6,8 +6,12 @@ import com.yutou.tools.ToolsApplication; import com.yutou.tools.mybatis.dao.UKeyDao; import com.yutou.tools.mybatis.model.UKey; import com.yutou.tools.mybatis.model.UKeyExample; +import com.yutou.tools.utils.ConfigTools; import com.yutou.tools.utils.RedisTools; import com.yutou.tools.utils.Tools; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.RequestMapping; @@ -122,6 +126,23 @@ public class tools { } return RedisTools.get("request"); } + @RequestMapping("/public/video.do") + public ResponseEntity getVideo(){ + return Tools.getFile(new File("Z:\\download\\anim\\鬼灭之刃\\[BeanSub&FZSD&LoliHouse] Kimetsu no Yaiba - 07 [WebRip 1080p HEVC-10bit AAC ASSx2]\\[BeanSub&FZSD&LoliHouse] Kimetsu no Yaiba - 07 [WebRip 1080p HEVC-10bit AAC ASSx2].mkv")); + } + //ffmpeg -i "[NC-Raws] 小林家的龙女仆S - 01 [B-Global][WEB-DL][2160p][AVC AAC][CHS_CHT_ENG_TH_SRT][MKV].mkv" -vn -an -map 0:2 sub2.srt + @RequestMapping("/public/sub.srt") + public ResponseEntity getVideoSub(){ + + return Tools.getFile(new File("Z:\\download\\anim\\鬼灭之刃\\[BeanSub&FZSD&LoliHouse] Kimetsu no Yaiba - 07 [WebRip 1080p HEVC-10bit AAC ASSx2].SC.ass")); + } + + @RequestMapping("/tools/server.do") + @ResponseBody + public String sendServer(String title,String msg){ + Tools.sendServer(title,msg); + return "ok"; + } public int getUid(HttpServletRequest request) { String token = request.getParameter("token"); diff --git a/src/main/java/com/yutou/tools/utils/Tools.java b/src/main/java/com/yutou/tools/utils/Tools.java index 44f85ea..cc2efca 100644 --- a/src/main/java/com/yutou/tools/utils/Tools.java +++ b/src/main/java/com/yutou/tools/utils/Tools.java @@ -265,7 +265,23 @@ public class Tools { downloadInterface.onError(e); } } - + public static ResponseEntity getFile(File file,MediaType mediaType){ + HttpHeaders headers = new HttpHeaders(); + //headers.add("Cache-Control", "no-cache, no-store, must-revalidate"); + try { + headers.add("Content-Disposition", "attachment; filename=" + URLEncoder.encode(file.getName(), "UTF-8")); + } catch (UnsupportedEncodingException e) { + headers.add("Content-Disposition", "attachment; filename=" + file.getName()); + } + //headers.add("Pragma", "no-cache"); + // headers.add("Expires", "0"); + // headers.add("Last-Modified", new Date().toString()); + // headers.add("ETag", String.valueOf(System.currentTimeMillis())); + headers.remove("Vary"); + headers.remove("Connection"); + headers.remove("Content-Disposition"); + return ResponseEntity.ok().headers(headers).contentLength(file.length()).contentType(mediaType).body(new FileSystemResource(file)); + } /** * 构造给前端的文件 * @@ -273,18 +289,7 @@ public class Tools { * @return 前端获取的文件 */ public static ResponseEntity getFile(File file) { - HttpHeaders headers = new HttpHeaders(); - headers.add("Cache-Control", "no-cache, no-store, must-revalidate"); - try { - headers.add("Content-Disposition", "attachment; filename=" + URLEncoder.encode(file.getName(), "UTF-8")); - } catch (UnsupportedEncodingException e) { - headers.add("Content-Disposition", "attachment; filename=" + file.getName()); - } - headers.add("Pragma", "no-cache"); - headers.add("Expires", "0"); - headers.add("Last-Modified", new Date().toString()); - headers.add("ETag", String.valueOf(System.currentTimeMillis())); - return ResponseEntity.ok().headers(headers).contentLength(file.length()).contentType(MediaType.parseMediaType("application/octet-stream")).body(new FileSystemResource(file)); + return getFile(file,MediaType.parseMediaType("application/octet-stream")); } public static String getFileMD5(File file) { diff --git a/src/test/java/com/yutou/tools/ToolsApplicationTests.java b/src/test/java/com/yutou/tools/ToolsApplicationTests.java index b39e391..87fde36 100644 --- a/src/test/java/com/yutou/tools/ToolsApplicationTests.java +++ b/src/test/java/com/yutou/tools/ToolsApplicationTests.java @@ -19,14 +19,9 @@ class ToolsApplicationTests { @Test void main(){ - List list=Tools.getUrls("com.yutou.tools",null); - for (String aClass : list) { - System.out.println(aClass); - } + } @Test void ptest(){ - JSONObject json=new AuthManagerController().getUserAuth("3"); - System.out.println(json.toJSONString()); } }