Materials { public String addMpNewsImage(InputStream inputStream, String fileName) { String url = WxEndpoint.get("url.mpnews.image.upload"); String response = wxClient.post(url, inputStream, fileName); Map<String, Object> result = JsonMapper.defaultMapper().json2Map(response); if (result.containsKey("url")) { return result.get("url").toString(); } else { logger.warn("mpnews image upload failed: {}", response); throw new WxRuntimeException(999, response); } }  static Materials defaultMaterials(); static Materials with(AppSetting appSetting); void setWxClient(WxClient wxClient); String addMpNewsImage(InputStream inputStream, String fileName); String addMpNews(MpNews mpNews); MpNews getMpNews(String mediaId); void updateMpNews(String mediaId, int index, MpArticle article); Material addVoice(InputStream inputStream, String fileName); InputStream getVoice(String mediaId); Material addImage(InputStream inputStream, String fileName); InputStream getImage(String mediaId); Material addThumb(InputStream inputStream, String fileName); InputStream getThumb(String mediaId); Material addVideo(InputStream inputStream, String fileName, String title, String description); Video getVideo(String mediaId); Counts count(); MaterialPagination list(MediaType mediaType, int offset, int count); MpNewsPagination listMpNews(int offset, int count); void delete(String mediaId);  }
@Test public void testAddMpNewsImage() throws IOException { InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("media/tetstt.jpg"); String url = Materials.defaultMaterials().addMpNewsImage(inputStream, "tetstt.jpg"); System.out.println("图片URL:" + url); }