@Test(dataProvider = "mediaData") public void testUploadMedia(String mediaType, String fileType, String fileName) throws WxErrorException, IOException { try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName)) { WxMediaUploadResult res = this.wxService.getMediaService().upload(mediaType, fileType, inputStream); assertThat(res).isNotNull(); assertThat(res.getType()).isNotEmpty(); assertThat(res.getCreatedAt()).isGreaterThan(0); assertTrue(res.getMediaId() != null || res.getThumbMediaId() != null); if (res.getMediaId() != null) { this.mediaIds.add(res.getMediaId()); } if (res.getThumbMediaId() != null) { this.mediaIds.add(res.getThumbMediaId()); } } }
@Override public WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException { return this.upload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType)); }
WxCpMediaServiceImpl implements WxCpMediaService { @Override public WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException { return this.upload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType)); } }
WxCpMediaServiceImpl implements WxCpMediaService { @Override public WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException { return this.upload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType)); } WxCpMediaServiceImpl(WxCpService mainService); }
WxCpMediaServiceImpl implements WxCpMediaService { @Override public WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException { return this.upload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType)); } 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 WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException { return this.upload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType)); } 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);  }