From 0fb6b9d8d414822668c401a2b507df1fe6d1fa2d Mon Sep 17 00:00:00 2001 From: zxl <763096477@qq.com> Date: 星期一, 16 六月 2025 14:28:08 +0800 Subject: [PATCH] 用户权限管理 --- framework/src/main/java/cn/lili/utils/COSUtil.java | 17 ++--------------- 1 files changed, 2 insertions(+), 15 deletions(-) diff --git a/framework/src/main/java/cn/lili/utils/COSUtil.java b/framework/src/main/java/cn/lili/utils/COSUtil.java index 23a2c23..c6b5731 100644 --- a/framework/src/main/java/cn/lili/utils/COSUtil.java +++ b/framework/src/main/java/cn/lili/utils/COSUtil.java @@ -114,6 +114,7 @@ cosSTS.setStsEndTime(cosSTS.getStsStartTime() + cosConfigProperty.getDurationSeconds() - 30); cosSTS.setBucket(cosConfigProperty.getBucket()); cosSTS.setRegion(cosConfigProperty.getRegion()); + cosSTS.setEndpoint(cosConfigProperty.getEndpoint()); return cosSTS; } catch (Exception e) { e.printStackTrace(); @@ -224,21 +225,7 @@ * @return */ public String getPreviewUrl(String fileKey) { - COSClient cosClient = this.initClient(); - // 璁剧疆绛惧悕杩囨湡鏃堕棿(鍙��), 鑻ユ湭杩涜璁剧疆鍒欓粯璁や娇鐢� ClientConfig 涓殑绛惧悕杩囨湡鏃堕棿(1灏忔椂) - // 杩欓噷璁剧疆绛惧悕鍦ㄥ崐涓皬鏃跺悗杩囨湡 - Date expirationDate = new Date(System.currentTimeMillis() + cosConfigProperty.getUrlExpireMinute() * 60 * 1000); - // 濉啓鏈璇锋眰鐨勫弬鏁帮紝闇�涓庡疄闄呰姹傜浉鍚岋紝鑳藉闃叉鐢ㄦ埛绡℃敼姝ょ鍚嶇殑 HTTP 璇锋眰鐨勫弬鏁� - Map<String, String> params = new HashMap<String, String>(); - // 濉啓鏈璇锋眰鐨勫ご閮紝闇�涓庡疄闄呰姹傜浉鍚岋紝鑳藉闃叉鐢ㄦ埛绡℃敼姝ょ鍚嶇殑 HTTP 璇锋眰鐨勫ご閮� - Map<String, String> headers = new HashMap<String, String>(); - // 璇锋眰鐨� HTTP 鏂规硶锛屼笂浼犺姹傜敤 PUT锛屼笅杞借姹傜敤 GET锛屽垹闄よ姹傜敤 DELETE - HttpMethodName method = HttpMethodName.GET; - URL url = cosClient.generatePresignedUrl(cosConfigProperty.getBucket(), fileKey, expirationDate, method, headers, params); - System.out.println(url.toString()); - // 纭鏈繘绋嬩笉鍐嶄娇鐢� cosClient 瀹炰緥涔嬪悗锛屽叧闂嵆鍙� - cosClient.shutdown(); - return url.toString(); + return cosConfigProperty.getEndpoint() + "/" + fileKey; } -- Gitblit v1.8.0