feat:【infra】s3 生成 presignGetUrl 时需要对 path 进行解码,解决文件名是中文时访问不到文件

This commit is contained in:
puhui999
2025-12-02 17:42:28 +08:00
parent cdc4255da1
commit 8aaead39bc
2 changed files with 12 additions and 1 deletions

View File

@@ -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());