@Test public void testAddMpNewsImage() { InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("media/image.png"); String url = Materials.defaultMaterials().addMpNewsImage(inputStream, "testMpNewsImage.png"); Assert.assertNotNull(url); }
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); } }
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); } } }
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); } }  }
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(CorpSetting corpSetting); void setWxClient(WxClient wxClient); String addMpNews(int agent, MpNews mpNews); void updateMpNews(int agent, String mediaId, MpNews mpNews); MpNews getMpNews(int agent, String mediaId); void deleteMpNews(int agentId, String mediaId); String upload(int agent, MediaType type, InputStream inputStream, String fileName); File download(int agent, String mediaId); void delete(int agent, String mediaId); String addMpNewsImage(InputStream inputStream, String fileName); Counts count(int agent); MaterialPagination list(int agentId, MediaType type, int offset, int size); MpNewsPagination listMpNews(int agentId, int offset, int size); }
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(CorpSetting corpSetting); void setWxClient(WxClient wxClient); String addMpNews(int agent, MpNews mpNews); void updateMpNews(int agent, String mediaId, MpNews mpNews); MpNews getMpNews(int agent, String mediaId); void deleteMpNews(int agentId, String mediaId); String upload(int agent, MediaType type, InputStream inputStream, String fileName); File download(int agent, String mediaId); void delete(int agent, String mediaId); String addMpNewsImage(InputStream inputStream, String fileName); Counts count(int agent); MaterialPagination list(int agentId, MediaType type, int offset, int size); MpNewsPagination listMpNews(int agentId, int offset, int size);  }