| | |
| | | |
| | | @PostMapping("/oss/sign") |
| | | public CommonResult ossSign(@RequestBody OssFileDto dto) { |
| | | log.info("接收到file"); |
| | | |
| | | DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | if (StringUtils.isNullOrEmpty(dto.getMediaId()) || StringUtils.isNullOrEmpty(dto.getExtension())) { |
| | | return CommonResult.failed("参数不能为空!"); |
| | | } |
| | | ExecutableClient executableClient = DdTest.getExecutableClient(); |
| | | CloseableHttpResponse response = null; |
| | | OSS ossClient = null; |
| | | |
| | | DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | System.out.println("开始获取--" + dtf2.format(LocalDateTime.now())); |
| | | try { |
| | |
| | | HttpEntity entity = response.getEntity(); |
| | | InputStream is = entity.getContent(); |
| | | |
| | | System.out.println("获取完成--" + dtf2.format(LocalDateTime.now())); |
| | | DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); |
| | | // MultipartFile file = getMultipartFile(is, fileName); |
| | | |
| | | String strDate2 = dtf.format(LocalDateTime.now()); |
| | | |
| | | String fileName = strDate2 + RandomUtils.generateRandomInt(4) + "." + dto.getExtension(); |
| | | MultipartFile file = getMultipartFile(is, fileName); |
| | | |
| | | String url = ossService.uploadImages(file); |
| | | String url = ossService.uploadImages(is,dto.getExtension()); |
| | | return CommonResult.success(url); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |