From a4a11fb50344e8277b2f85cf2bfed3987b0853e4 Mon Sep 17 00:00:00 2001 From: mediabot-pt <295750538+mediabot-pt@users.noreply.github.com> Date: Wed, 1 Jul 2026 18:14:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Qiniu=E4=B8=8B=E8=BD=BD=E5=85=88?= =?UTF-8?q?=E8=AF=95=E5=85=AC=E5=BC=80URL=E4=B8=8D=E7=94=A8=E7=AD=BE?= =?UTF-8?q?=E5=90=8D=EF=BC=8C=E7=BC=93=E5=AD=98=E5=B1=82CachedStorageServi?= =?UTF-8?q?ce=E5=B7=B2=E5=9C=A8=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/par/core/storage/QiniuStorageService.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/par-core/src/main/java/com/par/core/storage/QiniuStorageService.java b/par-core/src/main/java/com/par/core/storage/QiniuStorageService.java index d98f884..718937a 100644 --- a/par-core/src/main/java/com/par/core/storage/QiniuStorageService.java +++ b/par-core/src/main/java/com/par/core/storage/QiniuStorageService.java @@ -87,15 +87,20 @@ public class QiniuStorageService implements StorageService { log.warn("Qiniu stat 失败 {}: {}", path, e.response != null ? e.response.error : e.getMessage()); } - // 手动拼接 URL + privateDownloadUrl 签名 - String baseUrl = "http://" + downloadDomain + "/" + path; - String signedUrl = auth.privateDownloadUrl(baseUrl, 3600); + // 直接 HTTP 拉取(公开桶),不用签名 + String rawUrl = "http://" + downloadDomain + "/" + path; try { - var req = HttpRequest.newBuilder().uri(URI.create(signedUrl)) + var req = HttpRequest.newBuilder().uri(URI.create(rawUrl)) .timeout(Duration.ofSeconds(10)).GET().build(); var resp = httpClient.send(req, HttpResponse.BodyHandlers.ofString()); if (resp.statusCode() == 200) return resp.body(); - log.warn("Qiniu 下载失败 {}: HTTP {} url={}", path, resp.statusCode(), signedUrl); + // 公开桶失败,尝试签名URL + String signedUrl = auth.privateDownloadUrl(rawUrl, 3600); + req = HttpRequest.newBuilder().uri(URI.create(signedUrl)) + .timeout(Duration.ofSeconds(10)).GET().build(); + resp = httpClient.send(req, HttpResponse.BodyHandlers.ofString()); + if (resp.statusCode() == 200) return resp.body(); + log.warn("Qiniu 下载失败 {}: HTTP {}", path, resp.statusCode()); } catch (Exception e) { log.warn("Qiniu 下载失败 {}: {}", path, e.getMessage()); }