From bd3fb69befd63826975b281bbe23d05622496219 Mon Sep 17 00:00:00 2001 From: Daniel Qian Date: Wed, 27 May 2015 09:18:06 +0800 Subject: [PATCH 1/5] update to 1.1.6-SNAPSHOT --- README.md | 4 ++-- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f4ea8ca6..881af49c 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ weixin-java-tools me.chanjar weixin-java-mp - 1.1.5 + 1.1.6 ``` @@ -27,7 +27,7 @@ weixin-java-tools me.chanjar weixin-java-cp - 1.1.5 + 1.1.6 ``` diff --git a/pom.xml b/pom.xml index 090e4760..4511dbc7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 me.chanjar weixin-java-parent - 1.1.5 + 1.1.6-SNAPSHOT pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index b34d29be..05719571 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -6,7 +6,7 @@ me.chanjar weixin-java-parent - 1.1.5 + 1.1.6-SNAPSHOT weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index e7b75016..beef159f 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -6,7 +6,7 @@ me.chanjar weixin-java-parent - 1.1.5 + 1.1.6-SNAPSHOT weixin-java-cp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 3893b1cc..29bd5159 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -6,7 +6,7 @@ me.chanjar weixin-java-parent - 1.1.5 + 1.1.6-SNAPSHOT weixin-java-mp WeiXin Java Tools - MP From 622094bcdf8e1dbe3b4e4b06103b206e77cb6226 Mon Sep 17 00:00:00 2001 From: darknesstm Date: Wed, 3 Jun 2015 15:39:06 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E4=BD=BF=E7=94=A8getHttp?= =?UTF-8?q?Client=EF=BC=8C=E4=BD=BF=E5=BE=97=E5=8F=AF=E4=BB=A5=E5=A4=8D?= =?UTF-8?q?=E7=94=A8httpClient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java index 1e08a69f..ce198b08 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java @@ -108,8 +108,7 @@ public class WxMpServiceImpl implements WxMpService { RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build(); httpGet.setConfig(config); } - CloseableHttpClient httpclient = getHttpclient(); - CloseableHttpResponse response = httpclient.execute(httpGet); + CloseableHttpResponse response = getHttpclient().execute(httpGet); String resultContent = new BasicResponseHandler().handleResponse(response); WxError error = WxError.fromJson(resultContent); if (error.getErrorCode() != 0) { @@ -672,7 +671,7 @@ public class WxMpServiceImpl implements WxMpService { StringEntity entity = new StringEntity(xml, Consts.UTF_8); httpPost.setEntity(entity); try { - CloseableHttpResponse response = httpClient.execute(httpPost); + CloseableHttpResponse response = getHttpclient().execute(httpPost); String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); XStream xstream = XStreamInitializer.getInstance(); xstream.alias("xml", WxMpPrepayIdResult.class); From 50949b1ff516591f53fdc735d5d23499ba40d1c6 Mon Sep 17 00:00:00 2001 From: huansinho Date: Sun, 14 Jun 2015 01:16:20 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BF=BD=E7=95=A5eclipse?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 33606550..66e40382 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,23 @@ -*.class -test-output - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.ear - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -target -.project -.classpath - -sw-pom.xml -*.iml -test-config.xml -.idea +*.class +test-output + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +target +.project +.classpath +.settings + +sw-pom.xml +*.iml +test-config.xml +.idea From f107bd2f440cea5ff55f19bccea33fdbe5defccf Mon Sep 17 00:00:00 2001 From: huansinho Date: Sun, 14 Jun 2015 02:37:31 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9B=AE=E5=BD=95=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在下载多媒体文件下载时可以指定临时文件目录。 --- .../weixin/common/util/fs/FileUtils.java | 23 +++++++++++++++++-- .../http/MediaDownloadRequestExecutor.java | 14 ++++++++++- .../weixin/cp/api/WxCpConfigStorage.java | 4 ++++ .../cp/api/WxCpInMemoryConfigStorage.java | 13 +++++++++++ .../weixin/cp/api/WxCpServiceImpl.java | 16 ++++++++++++- .../weixin/mp/api/WxMpConfigStorage.java | 5 +++- .../mp/api/WxMpInMemoryConfigStorage.java | 17 ++++++++++++-- .../weixin/mp/api/WxMpServiceImpl.java | 4 +++- 8 files changed, 88 insertions(+), 8 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java index d2ecc42a..718f33e6 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java @@ -7,18 +7,25 @@ import java.io.InputStream; public class FileUtils { + /** * 创建临时文件 * @param inputStream * @param name 文件名 * @param ext 扩展名 + * @param tmpDirFile 临时文件夹目录 * @return * @throws IOException */ - public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException { + public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException { FileOutputStream fos = null; try { - File tmpFile = File.createTempFile(name, '.' + ext); + File tmpFile; + if (tmpDirFile == null) { + tmpFile = File.createTempFile(name, '.' + ext); + } else { + tmpFile = File.createTempFile(name, '.' + ext, tmpDirFile); + } tmpFile.deleteOnExit(); fos = new FileOutputStream(tmpFile); int read = 0; @@ -43,5 +50,17 @@ public class FileUtils { } } } + + /** + * 创建临时文件 + * @param inputStream + * @param name 文件名 + * @param ext 扩展名 + * @return + * @throws IOException + */ + public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException { + return createTmpFile(inputStream, name, ext, null); + } } diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java index dc7f28b4..32a7c917 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java @@ -25,6 +25,18 @@ import java.util.regex.Pattern; * */ public class MediaDownloadRequestExecutor implements RequestExecutor { + + private File tmpDirFile; + + public MediaDownloadRequestExecutor() { + super(); + } + + public MediaDownloadRequestExecutor(File tmpDirFile) { + super(); + this.tmpDirFile = tmpDirFile; + } + @Override public File execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String queryParam) throws WxErrorException, ClientProtocolException, IOException { @@ -59,7 +71,7 @@ public class MediaDownloadRequestExecutor implements RequestExecutor