diff --git a/changelog.txt b/changelog.txt index 361f8791..37acc9d9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,7 +2,12 @@ WEIXIN-POPULAR CHANGELOG =========================== https://github.com/liyiorg/weixin-popular -Changes in version 2.6.1 (2016-03-) +Changes in version 2.6.2 (2016-03-10) +------------------------------------- +* weixin.popular.api.MediaAPI bug 修复 + + +Changes in version 2.6.1 (2016-03-01) ------------------------------------- * MessageAPI 添加模板消息管理接口 * QrcodeAPI 添加永久二维码 字符串场景值接口 diff --git a/pom.xml b/pom.xml index eaaf4f2c..3ad4b33d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 weixin weixin-popular - 2.6.1-RELEASE + 2.6.2-RELEASE https://github.com/liyiorg/weixin-popular diff --git a/src/main/java/weixin/popular/api/MediaAPI.java b/src/main/java/weixin/popular/api/MediaAPI.java index 0c2da951..45080c93 100644 --- a/src/main/java/weixin/popular/api/MediaAPI.java +++ b/src/main/java/weixin/popular/api/MediaAPI.java @@ -181,9 +181,15 @@ public static UploadimgResult mediaUploadimg(String access_token,File media){ */ public static UploadimgResult mediaUploadimg(String access_token,InputStream inputStream){ HttpPost httpPost = new HttpPost(BASE_URI+"/cgi-bin/media/uploadimg"); - InputStreamBody inputStreamBody = new InputStreamBody(inputStream, ContentType.MULTIPART_FORM_DATA, UUID.randomUUID().toString()+".jpg"); + //InputStreamBody inputStreamBody = new InputStreamBody(inputStream, ContentType.DEFAULT_BINARY, UUID.randomUUID().toString()+".jpg"); + byte[] data = null; + try { + data = StreamUtils.copyToByteArray(inputStream); + } catch (IOException e) { + e.printStackTrace(); + } HttpEntity reqEntity = MultipartEntityBuilder.create() - .addPart("media",inputStreamBody) + .addBinaryBody("media",data,ContentType.DEFAULT_BINARY,"temp.jpg") .addTextBody(getATPN(), access_token) .build(); httpPost.setEntity(reqEntity);