public interface WxCpMediaService
媒体管理接口. Created by BinaryWang on 2017/6/24.
| 限定符和类型 | 方法和说明 | 
|---|---|
| File | download(String mediaId)
 下载多媒体文件. | 
| File | getJssdkFile(String mediaId)
 获取高清语音素材. | 
| WxMediaUploadResult | upload(String mediaType,
      File file)上传多媒体文件. | 
| WxMediaUploadResult | upload(String mediaType,
      File file,
      String filename)
   上传多媒体文件. | 
| WxMediaUploadResult | upload(String mediaType,
      InputStream inputStream,
      String filename)
   上传多媒体文件. | 
| WxMediaUploadResult | upload(String mediaType,
      String fileType,
      InputStream inputStream)
 上传多媒体文件. | 
| WxMediaUploadResult | upload(String mediaType,
      String filename,
      String url)
   上传多媒体文件. | 
| String | uploadImg(File file)
 上传图片. | 
WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException
上传多媒体文件. 上传的多媒体文件有格式和大小限制,如下: 图片(image): 1M,支持JPG格式 语音(voice):2M,播放长度不超过60s,支持AMR\MP3格式 视频(video):10MB,支持MP4格式 缩略图(thumb):64KB,支持JPG格式 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件
mediaType - 媒体类型, 请看WxConstsfileType - 文件类型,请看WxConstsinputStream - 输入流,需要调用方控制关闭该输入流WxErrorException - the wx error exceptionIOException - the io exceptionWxMediaUploadResult upload(String mediaType, String filename, String url) throws WxErrorException, IOException
上传多媒体文件.
mediaType - 媒体类型, 请看WxConstsfilename - 文件名.例如:wework.txturl - 远程链接WxErrorException - the wx error exceptionIOException - the io exceptionWxMediaUploadResult upload(String mediaType, File file, String filename) throws WxErrorException
上传多媒体文件.
mediaType - 媒体类型, 请看WxConstsfile - 文件对象, 上传的文件内容filename - 上传内容的实际文件名.例如:wework.txtWxErrorException - the wx error exceptionWxMediaUploadResult upload(String mediaType, InputStream inputStream, String filename) throws WxErrorException
上传多媒体文件.
mediaType - 媒体类型, 请看WxConstsinputStream - 上传的文件内容filename - 上传内容的实际文件名.例如:wework.txtWxErrorException - the wx error exceptionWxMediaUploadResult upload(String mediaType, File file) throws WxErrorException
mediaType - 媒体类型file - 文件对象WxErrorException - the wx error exception#upload(String, String, InputStream)File download(String mediaId) throws WxErrorException
下载多媒体文件. 根据微信文档,视频文件下载不了,会返回null 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件
mediaId - 媒体idWxErrorException - the wx error exceptionFile getJssdkFile(String mediaId) throws WxErrorException
获取高清语音素材. 可以使用本接口获取从JSSDK的uploadVoice接口上传的临时语音素材,格式为speex,16K采样率。该音频比上文的临时素材获取接口(格式为amr,8K采样率)更加清晰,适合用作语音识别等对音质要求较高的业务。 请求方式:GET(HTTPS) 请求地址:https://qyapi.weixin.qq.com/cgi-bin/media/get/jssdk?access_token=ACCESS_TOKEN&media_id=MEDIA_ID 仅企业微信2.4及以上版本支持。 文档地址:https://work.weixin.qq.com/api/doc#90000/90135/90255
mediaId - 媒体idWxErrorException - the wx error exceptionString uploadImg(File file) throws WxErrorException
上传图片. 上传图片得到图片URL,该URL永久有效 返回的图片URL,仅能用于图文消息(mpnews)正文中的图片展示;若用于非企业微信域名下的页面,图片将被屏蔽。 每个企业每天最多可上传100张图片 接口url格式:https://qyapi.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN
file - 上传的文件对象WxErrorException - the wx error exceptionCopyright © 2024. All rights reserved.