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