提交 67565fa7 编写于 作者: sq3536's avatar sq3536

免登

上级 d426f648
...@@ -95,9 +95,9 @@ public class DiskCoreResource ...@@ -95,9 +95,9 @@ public class DiskCoreResource
public void download(@PathVariable("folder") String folder, @PathVariable("id") String id, public void download(@PathVariable("folder") String folder, @PathVariable("id") String id,
@PathVariable(value = "name",required = false) String name, @PathVariable(value = "ext", required = false) String ext, @PathVariable(value = "name",required = false) String name, @PathVariable(value = "ext", required = false) String ext,
@RequestHeader(value = "authcode",required = false) String authcode, @RequestHeader(value = "authcode",required = false) String authcode,
@RequestParam(value = "authcode",required = false) String checkcode,HttpServletResponse response){ @RequestParam(value = "authcode",required = false) String checkcode,HttpServletRequest request,HttpServletResponse response){
File file = diskCoreService.getFile(folder,id, StringUtils.isEmpty(authcode)?checkcode:authcode); File file = diskCoreService.getFile(folder,id, StringUtils.isEmpty(authcode)?checkcode:authcode);
response.setHeader("Content-Disposition", "attachment;filename="+getFileName(file.getName())); response.setHeader("Content-Disposition", "attachment;filename="+getFileName(request.getHeader("User-Agent"),file.getName()));
this.sendRespose(response, file); this.sendRespose(response, file);
} }
...@@ -106,12 +106,12 @@ public class DiskCoreResource ...@@ -106,12 +106,12 @@ public class DiskCoreResource
public void open(@PathVariable("folder") String folder, @PathVariable("id") String id, public void open(@PathVariable("folder") String folder, @PathVariable("id") String id,
@PathVariable("name") String name, @PathVariable("ext") String ext, @PathVariable("name") String name, @PathVariable("ext") String ext,
@RequestHeader(value = "authcode",required = false) String authcode, @RequestHeader(value = "authcode",required = false) String authcode,
@RequestParam(value = "authcode",required = false) String checkcode,HttpServletResponse response){ @RequestParam(value = "authcode",required = false) String checkcode,HttpServletRequest request,HttpServletResponse response){
File file = diskCoreService.getFile(folder,id,StringUtils.isEmpty(authcode)?checkcode:authcode); File file = diskCoreService.getFile(folder,id,StringUtils.isEmpty(authcode)?checkcode:authcode);
String type = getType(DiskCoreService.getExtensionName(file)); String type = getType(DiskCoreService.getExtensionName(file));
response.setContentType(type); response.setContentType(type);
if(type.toLowerCase().equals("application/octet-stream")) if(type.toLowerCase().equals("application/octet-stream"))
response.setHeader("Content-Disposition", "attachment;filename="+getFileName(file.getName())); response.setHeader("Content-Disposition", "attachment;filename="+getFileName(request.getHeader("User-Agent"),file.getName()));
this.sendRespose(response, file); this.sendRespose(response, file);
} }
...@@ -178,7 +178,7 @@ public class DiskCoreResource ...@@ -178,7 +178,7 @@ public class DiskCoreResource
return ResponseEntity.status(HttpStatus.MOVED_PERMANENTLY).header(HttpHeaders.LOCATION, redirectUrl).build(); return ResponseEntity.status(HttpStatus.MOVED_PERMANENTLY).header(HttpHeaders.LOCATION, redirectUrl).build();
} }
@Value("${ibiz.file.proxy.editpath:http://172.16.180.233:9980/loleaflet/dist/loleaflet.html?file_path=}") @Value("${ibiz.file.proxy.editpath:http://172.16.180.233:39980/loleaflet/dist/loleaflet.html?file_path=}")
private String editPath; private String editPath;
@GetMapping(value = {"net-disk/editview/{folder}/{id}/{name}.{ext}","net-disk/edit/{folder}/{id}/{name}.{ext}"}) @GetMapping(value = {"net-disk/editview/{folder}/{id}/{name}.{ext}","net-disk/edit/{folder}/{id}/{name}.{ext}"})
...@@ -243,7 +243,7 @@ public class DiskCoreResource ...@@ -243,7 +243,7 @@ public class DiskCoreResource
response.reset(); response.reset();
// 设置response的Header // 设置response的Header
response.addHeader("Content-Disposition", "attachment;filename=" + response.addHeader("Content-Disposition", "attachment;filename=" +
getFileName(filename)); getFileName("",filename));
response.addHeader("Content-Length", "" + file.length()); response.addHeader("Content-Length", "" + file.length());
toClient = new BufferedOutputStream(response.getOutputStream()); toClient = new BufferedOutputStream(response.getOutputStream());
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
...@@ -320,9 +320,13 @@ public class DiskCoreResource ...@@ -320,9 +320,13 @@ public class DiskCoreResource
} }
} }
protected String getFileName(String fileName){ protected String getFileName(String userAgent,String fileName){
try { try {
return new String(fileName.getBytes("utf-8"),"ISO-8859-1");//防止中文乱码 if(userAgent.contains("MSIE")||userAgent.contains("Trident")) {
return java.net.URLEncoder.encode(fileName,"UTF-8");
}else {
return new String(fileName.getBytes("UTF-8"),"ISO-8859-1");
}
} }
catch (UnsupportedEncodingException e) { catch (UnsupportedEncodingException e) {
e.printStackTrace(); e.printStackTrace();
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册