| | |
| | | import com.ycl.config.DdTest; |
| | | import com.ycl.config.DingConfig; |
| | | import com.ycl.controller.BaseController; |
| | | import com.ycl.dto.video.OssFileDto; |
| | | import com.ycl.entity.dingding.DingUserInfo; |
| | | import com.ycl.service.auth.AuthService; |
| | | import com.ycl.service.ding.BookRemarkService; |
| | |
| | | |
| | | |
| | | @PostMapping("/oss/sign") |
| | | public CommonResult ossSign(@RequestParam("mediaId") String mediaId, @RequestParam("extension") String extension) { |
| | | public CommonResult ossSign(@RequestBody OssFileDto dto) { |
| | | log.info("接收到file"); |
| | | if (StringUtils.isNullOrEmpty(mediaId) || StringUtils.isNullOrEmpty(extension)) { |
| | | if (StringUtils.isNullOrEmpty(dto.getMediaId()) || StringUtils.isNullOrEmpty(dto.getExtension())) { |
| | | return CommonResult.failed("参数不能为空!"); |
| | | } |
| | | ExecutableClient executableClient = DdTest.getExecutableClient(); |
| | |
| | | String token = getToken(); |
| | | //设置参数 |
| | | getClient.addParameter("access_token", token); |
| | | getClient.addParameter("media_id", mediaId); |
| | | getClient.addParameter("media_id", dto.getMediaId()); |
| | | response = getClient.getB(); |
| | | HttpEntity entity = response.getEntity(); |
| | | InputStream is = entity.getContent(); |
| | |
| | | |
| | | String strDate2 = dtf2.format(LocalDateTime.now()); |
| | | |
| | | String fileName = strDate2 + RandomUtils.generateRandomInt(4) + "." + extension; |
| | | String fileName = strDate2 + RandomUtils.generateRandomInt(4) + "." + dto.getExtension(); |
| | | MultipartFile file = getMultipartFile(is, fileName); |
| | | String url = ossService.uploadImages(file); |
| | | return CommonResult.success(url); |