From 8aaead39bca6759dea3911a7abc83701cd12e906 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 2 Dec 2025 17:42:28 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90infra=E3=80=91s3=20?= =?UTF-8?q?=E7=94=9F=E6=88=90=20presignGetUrl=20=E6=97=B6=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E5=AF=B9=20path=20=E8=BF=9B=E8=A1=8C=E8=A7=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E8=A7=A3=E5=86=B3=E6=96=87=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E6=98=AF=E4=B8=AD=E6=96=87=E6=97=B6=E8=AE=BF=E9=97=AE=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/framework/common/util/http/HttpUtils.java | 11 +++++++++++ .../framework/file/core/client/s3/S3FileClient.java | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/http/HttpUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/http/HttpUtils.java index 85a644f1f1..10744d76bc 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/http/HttpUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/http/HttpUtils.java @@ -13,6 +13,7 @@ import org.springframework.web.util.UriComponents; import org.springframework.web.util.UriComponentsBuilder; import java.net.URI; +import java.net.URLDecoder; import java.net.URLEncoder; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; @@ -35,6 +36,16 @@ public class HttpUtils { return URLEncoder.encode(value, StandardCharsets.UTF_8); } + /** + * 解码 URL 参数 + * + * @param value 参数 + * @return 解码后的参数 + */ + public static String decodeUtf8(String value) { + return URLDecoder.decode(value, StandardCharsets.UTF_8); + } + @SuppressWarnings("unchecked") public static String replaceUrlQuery(String url, String key, String value) { UrlBuilder builder = UrlBuilder.of(url, Charset.defaultCharset()); diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java index d2213f5328..74a9361f99 100644 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java @@ -116,7 +116,7 @@ public class S3FileClient extends AbstractFileClient { public String presignGetUrl(String url, Integer expirationSeconds) { // 1. 将 url 转换为 path String path = StrUtil.removePrefix(url, config.getDomain() + "/"); - path = HttpUtils.removeUrlQuery(path); + path = HttpUtils.decodeUtf8(HttpUtils.removeUrlQuery(path)); // 2.1 情况一:公开访问:无需签名 // 考虑到老版本的兼容,所以必须是 config.getEnablePublicAccess() 为 false 时,才进行签名