From a1a7bb5093d30397078ce42ef025cd07378d1e1c Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期六, 25 四月 2026 15:26:59 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_New_pro' into dev_New_pro
---
src/main/java/com/ruoyi/basic/utils/FileUtil.java | 33 ++++++++++++++++++++++-----------
1 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/ruoyi/basic/utils/FileUtil.java b/src/main/java/com/ruoyi/basic/utils/FileUtil.java
index 6f1d5cf..d97d632 100644
--- a/src/main/java/com/ruoyi/basic/utils/FileUtil.java
+++ b/src/main/java/com/ruoyi/basic/utils/FileUtil.java
@@ -691,8 +691,28 @@
if (storageBlob == null || !StringUtils.hasText(storageBlob.getUidFilename())) {
throw new IllegalArgumentException("鏂囦欢淇℃伅涓嶅畬鏁�");
}
+ String domain = StringUtils.trimTrailingCharacter(properties.getDomain(), '/');
+ String prefix = properties.getUrlPrefix().startsWith("/") ? properties.getUrlPrefix() : "/" + properties.getUrlPrefix();
+ String normalizedActionPath = StringUtils.hasText(actionPath) ? actionPath : "/preview/";
+ if (!normalizedActionPath.startsWith("/")) {
+ normalizedActionPath = "/" + normalizedActionPath;
+ }
+ if (!normalizedActionPath.endsWith("/")) {
+ normalizedActionPath = normalizedActionPath + "/";
+ }
+ String baseUrl = domain + prefix + normalizedActionPath + storageBlob.getUidFilename();
+
+ // -1 琛ㄧず姘镐箙鏈夋晥锛屼笉鐢熸垚 token锛屾敼涓� publicKey 缁勫悎鏍¢獙
+ if (expired != null && BigDecimal.valueOf(-1L).compareTo(expired) == 0) {
+ if (!StringUtils.hasText(storageBlob.getResourceKey())) {
+ throw new IllegalArgumentException("鍏紑閾炬帴缂哄皯publicKey");
+ }
+ return baseUrl + "?publicKey=" + storageBlob.getResourceKey();
+ }
+
long now = System.currentTimeMillis();
- long expiredMillis = expired.multiply(new BigDecimal("60000")).longValue();
+ BigDecimal expiredValue = expired == null ? new BigDecimal("120") : expired;
+ long expiredMillis = expiredValue.multiply(new BigDecimal("60000")).longValue();
if (expiredMillis <= 0L) {
expiredMillis = 2L * 60L * 60L * 1000L;
}
@@ -709,16 +729,7 @@
.signWith(key) // 閲嶇偣锛氫紶鍏ヤ笂闈㈢敓鎴愮殑 key 瀵硅薄锛岃�屼笉鏄� String
.compact();
cacheTokenUsage(token, expiredMillis);
- String domain = StringUtils.trimTrailingCharacter(properties.getDomain(), '/');
- String prefix = properties.getUrlPrefix().startsWith("/") ? properties.getUrlPrefix() : "/" + properties.getUrlPrefix();
- String normalizedActionPath = StringUtils.hasText(actionPath) ? actionPath : "/preview/";
- if (!normalizedActionPath.startsWith("/")) {
- normalizedActionPath = "/" + normalizedActionPath;
- }
- if (!normalizedActionPath.endsWith("/")) {
- normalizedActionPath = normalizedActionPath + "/";
- }
- return domain + prefix + normalizedActionPath + storageBlob.getUidFilename() + "?token=" + token;
+ return baseUrl + "?token=" + token;
}
private void cacheTokenUsage(String token, long expiredMillis) {
--
Gitblit v1.9.3