|
@@ -5,6 +5,7 @@ package com.jeeplus.modules.caseinfo.web;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
+import com.jeeplus.common.bos.BOSClientUtil;
|
|
|
import com.jeeplus.common.config.Global;
|
|
|
import com.jeeplus.common.json.AjaxJson;
|
|
|
import com.jeeplus.common.oss.OSSClientUtil;
|
|
@@ -73,8 +74,11 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.ConstraintViolationException;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
@@ -925,21 +929,52 @@ public class CaseInfoController extends BaseController {
|
|
|
*/
|
|
|
@RequestMapping("/downLoadAttach")
|
|
|
public String downLoadAttach(@RequestParam("file") String file,HttpServletRequest request,HttpServletResponse response) throws IOException {
|
|
|
- file = file.replace("amp;","");
|
|
|
- String fileName = file.substring(file.lastIndexOf("/") + 1, file.length());
|
|
|
- String aliyunUrl = Global.getAliyunUrl();
|
|
|
- String aliDownloadUrl = Global.getAliDownloadUrl();
|
|
|
- String cons = "";
|
|
|
- if (file.contains(aliyunUrl)){
|
|
|
- cons = aliyunUrl;
|
|
|
- }else if (file.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")){
|
|
|
- cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
|
|
|
- }else {
|
|
|
- cons = aliDownloadUrl;
|
|
|
+// file = file.replace("amp;","");
|
|
|
+// String fileName = file.substring(file.lastIndexOf("/") + 1, file.length());
|
|
|
+// String aliyunUrl = Global.getAliyunUrl();
|
|
|
+// String aliDownloadUrl = Global.getAliDownloadUrl();
|
|
|
+// String cons = "";
|
|
|
+// if (file.contains(aliyunUrl)){
|
|
|
+// cons = aliyunUrl;
|
|
|
+// }else if (file.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")){
|
|
|
+// cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
|
|
|
+// }else {
|
|
|
+// cons = aliDownloadUrl;
|
|
|
+// }
|
|
|
+// String key = file.split(cons+"/")[1];
|
|
|
+// new OSSClientUtil().downByStream(key,fileName,response,request.getHeader("USER-AGENT"));
|
|
|
+// return null;
|
|
|
+ OutputStream out = null;
|
|
|
+ InputStream in = null;
|
|
|
+ try {
|
|
|
+ file = URLDecoder.decode(file,"UTF-8");
|
|
|
+ String path = file.substring(file.indexOf(".com") + 4, file.length());
|
|
|
+ String fileName = URLEncoder.encode(file.substring(file.lastIndexOf("/") + 1, file.length()),"UTF-8");
|
|
|
+ BOSClientUtil bosClientUtil = new BOSClientUtil();
|
|
|
+ in = bosClientUtil.getObject(path);
|
|
|
+ response.reset();//重置 响应头
|
|
|
+ response.setContentType("application/x-download");
|
|
|
+ response.setHeader("Content-disposition", "attachment; filename=" + fileName);
|
|
|
+ out = response.getOutputStream();
|
|
|
+ byte[] b = new byte[1024];
|
|
|
+ int len;
|
|
|
+ while ((len = in.read(b)) > 0){
|
|
|
+ response.getOutputStream().write(b, 0, len);
|
|
|
+ }
|
|
|
+ in.close();
|
|
|
+ out.close();
|
|
|
+ }catch (IOException e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }finally {
|
|
|
+ if (out != null) {
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+ if (in != null) {
|
|
|
+ in.close();
|
|
|
+ }
|
|
|
}
|
|
|
- String key = file.split(cons+"/")[1];
|
|
|
- new OSSClientUtil().downByStream(key,fileName,response,request.getHeader("USER-AGENT"));
|
|
|
- return null;
|
|
|
+ return null;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|