| | |
| | | } |
| | | |
| | | @GetMapping("/downLoadFile") |
| | | public AjaxResult downLoadFile(@PathParam("path") String path, HttpServletResponse response) throws Exception { |
| | | return downLoadFileService.downLoadFile(path,response); |
| | | public void downLoadFile(@PathParam("path") String path, HttpServletResponse response) throws Exception { |
| | | downLoadFileService.downLoadFile(path,response); |
| | | } |
| | | |
| | | |
| | |
| | | * @Date 2023-03-19 17:32 |
| | | */ |
| | | public interface DownLoadFileService { |
| | | AjaxResult downLoadFile(String path, HttpServletResponse response); |
| | | void downLoadFile(String path, HttpServletResponse response); |
| | | } |
| | |
| | | private String basePath; |
| | | |
| | | @Override |
| | | public AjaxResult downLoadFile(String path, HttpServletResponse response) { |
| | | public void downLoadFile(String path, HttpServletResponse response) { |
| | | |
| | | path=basePath+path.substring(8); |
| | | File file = new File(path); |
| | |
| | | while(bis.read(buffer) != -1){ |
| | | os.write(buffer); |
| | | } |
| | | return AjaxResult.success("操作成功"); |
| | | } |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return AjaxResult.error("操作失败"); |
| | | } |
| | | } |