@Test public void testUploadImg() throws WxErrorException { URL url = ClassLoader.getSystemResource("mm.jpeg"); String res = this.wxService.getMediaService().uploadImg(new File(url.getFile())); assertThat(res).isNotEmpty(); }
@Override public String uploadImg(File file) throws WxErrorException { final WxMediaUploadResult result = this.mainService .execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), IMG_UPLOAD_URL, file); return result.getUrl(); }
WxCpMediaServiceImpl implements WxCpMediaService { @Override public String uploadImg(File file) throws WxErrorException { final WxMediaUploadResult result = this.mainService .execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), IMG_UPLOAD_URL, file); return result.getUrl(); } }
WxCpMediaServiceImpl implements WxCpMediaService { @Override public String uploadImg(File file) throws WxErrorException { final WxMediaUploadResult result = this.mainService .execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), IMG_UPLOAD_URL, file); return result.getUrl(); } WxCpMediaServiceImpl(WxCpService mainService); }
WxCpMediaServiceImpl implements WxCpMediaService { @Override public String uploadImg(File file) throws WxErrorException { final WxMediaUploadResult result = this.mainService .execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), IMG_UPLOAD_URL, file); return result.getUrl(); } WxCpMediaServiceImpl(WxCpService mainService); @Override WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream); @Override WxMediaUploadResult upload(String mediaType, File file); @Override File download(String mediaId); @Override File getJssdkFile(String mediaId); @Override String uploadImg(File file); }
WxCpMediaServiceImpl implements WxCpMediaService { @Override public String uploadImg(File file) throws WxErrorException { final WxMediaUploadResult result = this.mainService .execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), IMG_UPLOAD_URL, file); return result.getUrl(); } WxCpMediaServiceImpl(WxCpService mainService); @Override WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream); @Override WxMediaUploadResult upload(String mediaType, File file); @Override File download(String mediaId); @Override File getJssdkFile(String mediaId); @Override String uploadImg(File file);  }