如果有有java后端代码如下
@SneakyThrows@ApiOperation("访问文件")@GetMapping("/download/{name}")public void getImage(HttpServletResponse response, @PathVariable("name") String name) {String imagePath = uploadFilePath + File.separator + name;if (!new File(imagePath).exists()) {return;}if (name.endsWith("jpg") || name.endsWith("png") || name.endsWith("gif") || name.endsWith("jpeg")) {response.setContentType("image/jpeg;charset=utf-8");} else {response.setContentType("application/octet-stream");response.setHeader("Content-Disposition", "inline; filename=" + URLEncoder.encode(name, "UTF-8"));}ServletOutputStream outputStream = response.getOutputStream();outputStream.write(Files.readAllBytes(Paths.get(uploadFilePath).resolve(name)));outputStream.flush();outputStream.close();}
在360浏览器安装如下插件,打开请求访问的就不是下载,而是直接在浏览器预览

