| | |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.xxpt.gateway.shared.api.request.OapiMediaUploadRequest; |
| | | import com.alibaba.xxpt.gateway.shared.api.response.OapiMediaUploadResponse; |
| | | import com.alibaba.xxpt.gateway.shared.client.http.ExecutableClient; |
| | | import com.alibaba.xxpt.gateway.shared.client.http.GetClient; |
| | | import com.alibaba.xxpt.gateway.shared.client.http.IntelligentPostClient; |
| | | import com.alibaba.xxpt.gateway.shared.client.http.PostClient; |
| | | import com.aliyun.oss.OSS; |
| | | import com.aliyun.oss.OSSClientBuilder; |
| | |
| | | public CommonResult<String> getVideo(@PathVariable String mediaId) { |
| | | String accessToken = getToken(); |
| | | |
| | | |
| | | //executableClient保证单例 |
| | | IntelligentPostClient intelligentPostClient = executableClient.newIntelligentPostClient("/media/upload"); |
| | | OapiMediaUploadRequest oapiMediaUploadRequest = new OapiMediaUploadRequest(); |
| | | //调用接口凭证 |
| | | oapiMediaUploadRequest.setAccess_token(accessToken); |
| | | //媒体文件类型,分别有图片(image)、语音(voice)、普通文件(file) |
| | | oapiMediaUploadRequest.setType("file"); |
| | | //orm-data中媒体文件标识,有filename、filelength、content-type等信息 |
| | | oapiMediaUploadRequest.setMedia("filename"); |
| | | intelligentPostClient.addFile(new File("F:\\视频\\7月29日.mp4")); |
| | | //获取结果 |
| | | OapiMediaUploadResponse apiResult = intelligentPostClient.post(oapiMediaUploadRequest); |
| | | |
| | | |
| | | MultipartFile file = getDownload(accessToken, mediaId); |
| | | String url = ossService.uploadImages(file); |
| | | return CommonResult.success(url); |