Bladeren bron

Merge remote-tracking branch 'origin/master'

user4 5 jaren geleden
bovenliggende
commit
d6b85006da

+ 49 - 14
src/main/java/com/jeeplus/modules/caseinfo/web/CaseInfoController.java

@@ -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;
+
 	}
 
 	/**

+ 45 - 14
src/main/java/com/jeeplus/modules/workcontractinfo/web/WorkContractInfoAlterController.java

@@ -7,6 +7,7 @@ import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.jeeplus.common.beanvalidator.BeanValidators;
+import com.jeeplus.common.bos.BOSClientUtil;
 import com.jeeplus.common.config.Global;
 import com.jeeplus.common.oss.OSSClientUtil;
 import com.jeeplus.common.persistence.Page;
@@ -67,6 +68,7 @@ import javax.servlet.http.HttpServletResponse;
 import javax.validation.ConstraintViolationException;
 import java.io.*;
 import java.net.URLDecoder;
+import java.net.URLEncoder;
 import java.util.*;
 
 /**
@@ -1420,21 +1422,50 @@ public class WorkContractInfoAlterController extends BaseController {
      */
     @RequestMapping("/downLoadAttach")
     public void downLoadAttach(@RequestParam("file") String file, 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;
+//        }
+//        final String[] arr = file.split(cons + "/");
+//        String key = arr[1];
+//        new OSSClientUtil().downByStream(key, fileName, response,request.getHeader("USER-AGENT"));
+        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();
+            }
         }
-        final String[] arr = file.split(cons + "/");
-        String key = arr[1];
-        new OSSClientUtil().downByStream(key, fileName, response,request.getHeader("USER-AGENT"));
     }
 
     /**

+ 45 - 14
src/main/java/com/jeeplus/modules/workcontractinfo/web/WorkContractInfoController.java

@@ -8,6 +8,7 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.zxing.aztec.decoder.Decoder;
 import com.jeeplus.common.beanvalidator.BeanValidators;
+import com.jeeplus.common.bos.BOSClientUtil;
 import com.jeeplus.common.config.Global;
 import com.jeeplus.common.json.AjaxJson;
 import com.jeeplus.common.oss.OSSClientUtil;
@@ -76,6 +77,7 @@ import javax.servlet.http.HttpServletResponse;
 import javax.validation.ConstraintViolationException;
 import java.io.*;
 import java.net.URLDecoder;
+import java.net.URLEncoder;
 import java.util.*;
 
 /**
@@ -1458,21 +1460,50 @@ public class WorkContractInfoController extends BaseController {
      */
     @RequestMapping("/downLoadAttach")
     public void downLoadAttach(@RequestParam("file") String file, 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;
+//        }
+//        final String[] arr = file.split(cons + "/");
+//        String key = arr[1];
+//        new OSSClientUtil().downByStream(key, fileName, response,request.getHeader("USER-AGENT"));
+        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();
+            }
         }
-        final String[] arr = file.split(cons + "/");
-        String key = arr[1];
-        new OSSClientUtil().downByStream(key, fileName, response,request.getHeader("USER-AGENT"));
     }
 
     /**

+ 45 - 14
src/main/java/com/jeeplus/modules/workcontractinfo/web/WorkContractInfoInvalidateController.java

@@ -7,6 +7,7 @@ import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.jeeplus.common.beanvalidator.BeanValidators;
+import com.jeeplus.common.bos.BOSClientUtil;
 import com.jeeplus.common.config.Global;
 import com.jeeplus.common.oss.OSSClientUtil;
 import com.jeeplus.common.persistence.Page;
@@ -68,6 +69,7 @@ import javax.servlet.http.HttpServletResponse;
 import javax.validation.ConstraintViolationException;
 import java.io.*;
 import java.net.URLDecoder;
+import java.net.URLEncoder;
 import java.util.*;
 
 /**
@@ -1561,21 +1563,50 @@ public class WorkContractInfoInvalidateController extends BaseController {
      */
     @RequestMapping("/downLoadAttach")
     public void downLoadAttach(@RequestParam("file") String file, 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;
+//        }
+//        final String[] arr = file.split(cons + "/");
+//        String key = arr[1];
+//        new OSSClientUtil().downByStream(key, fileName, response,request.getHeader("USER-AGENT"));
+        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();
+            }
         }
-        final String[] arr = file.split(cons + "/");
-        String key = arr[1];
-        new OSSClientUtil().downByStream(key, fileName, response,request.getHeader("USER-AGENT"));
     }
 
     /**