From 6c7549ca8e30a2e1b4347cded1d147e859b60d83 Mon Sep 17 00:00:00 2001 From: mediabot-pt <295750538+mediabot-pt@users.noreply.github.com> Date: Tue, 30 Jun 2026 18:21:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Qiniu=20=E4=B8=8B=E8=BD=BD=E6=94=B9?= =?UTF-8?q?=E7=94=A8=20privateDownloadUrl=20=E6=89=8B=E5=8A=A8=E6=8B=BC?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/par/core/storage/QiniuStorageService.java | 8 +++----- 1 file changed, 3 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 0e2fa36..cd9fa8f 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 @@ -3,7 +3,6 @@ package com.par.core.storage; import com.qiniu.common.QiniuException; import com.qiniu.storage.BucketManager; import com.qiniu.storage.Configuration; -import com.qiniu.storage.DownloadUrl; import com.qiniu.storage.Region; import com.qiniu.storage.UploadManager; import com.qiniu.util.Auth; @@ -93,11 +92,10 @@ public class QiniuStorageService implements StorageService { log.warn("Qiniu stat 失败 {}: {}", path, e.response != null ? e.response.error : e.getMessage()); } - // 用 DownloadUrl 生成带签名的下载链接 - long deadline = System.currentTimeMillis() / 1000 + 3600; + // 手动拼接 URL + privateDownloadUrl 签名 + String baseUrl = "http://" + downloadDomain + "/" + path; + String signedUrl = auth.privateDownloadUrl(baseUrl, 3600); try { - DownloadUrl url = new DownloadUrl(downloadDomain, useHttps, path); - String signedUrl = url.buildURL(auth, deadline); var req = HttpRequest.newBuilder().uri(URI.create(signedUrl)) .timeout(Duration.ofSeconds(10)).GET().build(); var resp = httpClient.send(req, HttpResponse.BodyHandlers.ofString());