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

免登

上级 d426f648
......@@ -95,9 +95,9 @@ public class DiskCoreResource
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,
@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);
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);
}
......@@ -106,12 +106,12 @@ public class DiskCoreResource
public void open(@PathVariable("folder") String folder, @PathVariable("id") String id,
@PathVariable("name") String name, @PathVariable("ext") String ext,
@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);
String type = getType(DiskCoreService.getExtensionName(file));
response.setContentType(type);
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);
}
......@@ -178,7 +178,7 @@ public class DiskCoreResource
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;
@GetMapping(value = {"net-disk/editview/{folder}/{id}/{name}.{ext}","net-disk/edit/{folder}/{id}/{name}.{ext}"})
......@@ -243,7 +243,7 @@ public class DiskCoreResource
response.reset();
// 设置response的Header
response.addHeader("Content-Disposition", "attachment;filename=" +
getFileName(filename));
getFileName("",filename));
response.addHeader("Content-Length", "" + file.length());
toClient = new BufferedOutputStream(response.getOutputStream());
response.setContentType("application/octet-stream");
......@@ -320,9 +320,13 @@ public class DiskCoreResource
}
}
protected String getFileName(String fileName){
protected String getFileName(String userAgent,String fileName){
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) {
e.printStackTrace();
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册