From 606290e185b1c95b3379db39799f22fe02b39bcd Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期一, 08 一月 2024 12:04:44 +0800 Subject: [PATCH] !477 JustAuth 整合 TopIam 单点登录 Merge pull request !477 from 马铃薯头/dev --- ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/core/OssClient.java | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/core/OssClient.java b/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/core/OssClient.java index 992e3d4..53e05c9 100644 --- a/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/core/OssClient.java +++ b/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/core/OssClient.java @@ -24,6 +24,7 @@ import org.dromara.common.oss.properties.OssProperties; import java.io.ByteArrayInputStream; +import java.io.File; import java.io.InputStream; import java.net.URL; import java.util.Date; @@ -115,6 +116,18 @@ return UploadResult.builder().url(getUrl() + "/" + path).filename(path).build(); } + public UploadResult upload(File file, String path) { + try { + PutObjectRequest putObjectRequest = new PutObjectRequest(properties.getBucketName(), path, file); + // 璁剧疆涓婁紶瀵硅薄鐨� Acl 涓哄叕鍏辫 + putObjectRequest.setCannedAcl(getAccessPolicy().getAcl()); + client.putObject(putObjectRequest); + } catch (Exception e) { + throw new OssException("涓婁紶鏂囦欢澶辫触锛岃妫�鏌ラ厤缃俊鎭�:[" + e.getMessage() + "]"); + } + return UploadResult.builder().url(getUrl() + "/" + path).filename(path).build(); + } + public void delete(String path) { path = path.replace(getUrl() + "/", ""); try { @@ -132,6 +145,10 @@ return upload(inputStream, getPath(properties.getPrefix(), suffix), contentType); } + public UploadResult uploadSuffix(File file, String suffix) { + return upload(file, getPath(properties.getPrefix(), suffix)); + } + /** * 鑾峰彇鏂囦欢鍏冩暟鎹� * -- Gitblit v1.9.3