From dbfb8c8c9903f93d1d1f0bae8568434a5a45af37 Mon Sep 17 00:00:00 2001 From: xudawei Date: Fri, 26 Apr 2024 13:46:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E9=80=9A=E8=BF=87url?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6-=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E6=9E=84=E5=BB=BAhttp=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/FileByUrlServiceImpl.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/oss-service/src/main/java/cn/axzo/oss/service/impl/FileByUrlServiceImpl.java b/oss-service/src/main/java/cn/axzo/oss/service/impl/FileByUrlServiceImpl.java index 1721be0..14d08c0 100644 --- a/oss-service/src/main/java/cn/axzo/oss/service/impl/FileByUrlServiceImpl.java +++ b/oss-service/src/main/java/cn/axzo/oss/service/impl/FileByUrlServiceImpl.java @@ -122,17 +122,38 @@ public class FileByUrlServiceImpl implements FileByUrlService { @Autowired private LogPlatClient logPlatClient; + @Autowired + private FileService fileService; + /** * 通过url上传 */ @Override public ServerFileUploadResponse uploadByUrl(String appCode, String bizScene, String fileName, String url, Integer channelType, ContextInfo.LiteSaasContext liteSaasContext) { + //重新构建链接 + url = this.rebuildUrl(url); File ossFile = uploadFileAndGetFile(appCode, bizScene, fileName, url, channelType); //操作日志记录 operateLog(this.buildUploadParams(appCode, bizScene, fileName, url, channelType), "", FILE_UPLOAD_CODE, FILE_UPLOAD_NAME, liteSaasContext); return buildResponse(ossFile); } + /** + * url:https://xxx,则直接返回 + * url:fileKey,则返回https://链接 + */ + private String rebuildUrl(String url) { + if (StringUtils.isNotBlank(url)) { + FindFileUrlDto findFileUrlDto = FindFileUrlDto.builder().fileKey(Lists.newArrayList(url)).build(); + + List responseList = fileService.findFileUrl(findFileUrlDto); + if (CollectionUtil.isNotEmpty(responseList)) { + return responseList.get(0).getUrl(); + } + } + return StringUtils.EMPTY; + } + /** * 操作日志记录 */