Skip to content

Commit

Permalink
MediaAPI bug 修复
Browse files Browse the repository at this point in the history
  • Loading branch information
liyiorg committed Mar 10, 2016
1 parent a2f048b commit 657edad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 添加永久二维码 字符串场景值接口
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>weixin</groupId>
<artifactId>weixin-popular</artifactId>
<version>2.6.1-RELEASE</version>
<version>2.6.2-RELEASE</version>
<url>https://github.com/liyiorg/weixin-popular</url>

<dependencies>
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/weixin/popular/api/MediaAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 657edad

Please sign in to comment.