From 0546530fe7e1696cf3ae4eaf9e79a5e7c4e203fe Mon Sep 17 00:00:00 2001
From: ANDRU-PC\Andru <769883346@qq.com>
Date: 星期四, 21 七月 2022 18:43:26 +0800
Subject: [PATCH] Merge branch 'master' of http://1.15.4.62/r/~chenjiahe/hx_common

---
 src/main/java/com/hx/mp/util/MPWeixinBaseUtil.java |   43 ++++++++++++++++++++++++++++++-------------
 1 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/hx/mp/util/MPWeixinBaseUtil.java b/src/main/java/com/hx/mp/util/MPWeixinBaseUtil.java
index 8a52d18..e3e2562 100644
--- a/src/main/java/com/hx/mp/util/MPWeixinBaseUtil.java
+++ b/src/main/java/com/hx/mp/util/MPWeixinBaseUtil.java
@@ -606,14 +606,25 @@
 	}
 
 
-	/**鐢熸垚鏃犻檺浜岀淮鐮侊紝骞朵笂浼犲埌OSS*/
-	public static String createUnlimitQrCode(String at, String scene, String page, int width, boolean autoColor,
-											 JSONObject lineColor, boolean isHyaline, String fileName, String keyId,
-											 String keySecret, String endPoint, String bucket, String env_version)
-	{
+
+	/**鐢熸垚鏃犻檺浜岀淮鐮�,杩斿洖涓存椂鏂�
+	 * @param at 寰俊token
+	 * @param scene 鍙傛暟锛屽彧鑳�32浣嶏紝鏈�濂戒笉瑕佷腑鏂�
+	 * @param page 璺宠浆閾炬帴
+	 * @param width 瀹藉害
+	 * @param autoColor 榛樿false
+	 * @param lineColor 榛樿null
+	 * @param isHyaline 榛樿false
+	 * @return
+	 */
+	public static File createUnlimitQrCode(String at, String scene, String page, int width, boolean autoColor,
+										   JSONObject lineColor, boolean isHyaline, String env_version) throws IOException {
 		String imgUrl = null;
 		InputStream in = null;
 		HttpURLConnection conn = null;
+
+		//鍒涘缓涓存椂鏂囦欢
+		File file = File.createTempFile("temp", ".jpg");
 
 		try {
 			//鐢熸垚鍙戦�佹暟鎹�
@@ -654,7 +665,15 @@
 			if (conn.getResponseCode() == 200) {
 				// 璇锋眰杩斿洖鐨勬暟鎹�
 				in = conn.getInputStream();
-				imgUrl = OSSUtil.uploadImg(fileName, in, keyId, keySecret, endPoint, bucket);
+				//杈撳叆鍒颁复鏃舵枃浠�
+				/*OutputStream os = new FileOutputStream(file);
+				int bytesRead = 0;
+				byte[] buffer = new byte[8192];
+				while ((bytesRead = in.read(buffer, 0, 8192)) != -1) {
+					os.write(buffer, 0, bytesRead);
+				}*/
+				FileUtils.copyInputStreamToFile(in, file);
+
 				conn.disconnect();
 				conn = null;
 			}
@@ -668,15 +687,12 @@
 				conn.disconnect();
 				conn = null;
 			}
-		}catch (Exception e)
-		{
+		}catch (Exception e) {
 			e.printStackTrace();
-
 			if (in != null) {
 				try {
 					in.close();
-				}catch (Exception ep)
-				{
+				}catch (Exception ep) {
 					ep.printStackTrace();
 				}
 				in = null;
@@ -686,9 +702,10 @@
 				conn.disconnect();
 				conn = null;
 			}
+		}finally {
+			file.deleteOnExit();
 		}
-
-		return imgUrl;
+		return file;
 	}
 
 }

--
Gitblit v1.8.0