mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-18 14:23:39 +00:00
v3.0.0 init
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -27,16 +26,41 @@
|
||||
<artifactId>ruoyi-common-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- AWS SDK for Java 2.x -->
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-s3</artifactId>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>s3</artifactId>
|
||||
<exclusions>
|
||||
<!-- 将基于 CRT 的 HTTP 客户端从类路径中移除 -->
|
||||
<exclusion>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>aws-crt-client</artifactId>
|
||||
</exclusion>
|
||||
<!-- 将基于 Apache 的 HTTP 客户端从类路径中移除 -->
|
||||
<exclusion>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>apache-client</artifactId>
|
||||
</exclusion>
|
||||
<!-- 将配置基于 URL 连接的 HTTP 客户端从类路径中移除 -->
|
||||
<exclusion>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>url-connection-client</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- 将基于 Netty 的 HTTP 客户端从类路径中移除 -->
|
||||
<dependency>
|
||||
<groupId>com.qcloud</groupId>
|
||||
<artifactId>cos_api</artifactId>
|
||||
<version>5.6.75</version>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>netty-nio-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 基于 AWS CRT 的 S3 客户端的性能增强的 S3 传输管理器 -->
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>s3-transfer-manager</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.ruoyi.common.oss.constant;
|
||||
|
||||
import org.ruoyi.common.core.constant.GlobalConstants;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,7 +15,7 @@ public interface OssConstant {
|
||||
/**
|
||||
* 默认配置KEY
|
||||
*/
|
||||
String DEFAULT_CONFIG_KEY = "sys_oss:default_config";
|
||||
String DEFAULT_CONFIG_KEY = GlobalConstants.GLOBAL_REDIS_KEY + "sys_oss:default_config";
|
||||
|
||||
/**
|
||||
* 预览列表资源开关Key
|
||||
@@ -28,7 +30,7 @@ public interface OssConstant {
|
||||
/**
|
||||
* 云服务商
|
||||
*/
|
||||
String[] CLOUD_SERVICE = new String[]{"aliyun", "qcloud", "qiniu", "obs"};
|
||||
String[] CLOUD_SERVICE = new String[] {"aliyun", "qcloud", "qiniu", "obs"};
|
||||
|
||||
/**
|
||||
* https 状态
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
package org.ruoyi.common.oss.core;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 写出订阅器
|
||||
*
|
||||
* @author 秋辞未寒
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface WriteOutSubscriber<T> {
|
||||
|
||||
void writeTo(T out) throws IOException;
|
||||
|
||||
}
|
||||
@@ -21,4 +21,10 @@ public class UploadResult {
|
||||
* 文件名
|
||||
*/
|
||||
private String filename;
|
||||
|
||||
/**
|
||||
* 已上传对象的实体标记(用来校验文件)
|
||||
*/
|
||||
private String eTag;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package org.ruoyi.common.oss.enumd;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* minio策略配置
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PolicyType {
|
||||
|
||||
/**
|
||||
* 只读
|
||||
*/
|
||||
READ("read-only"),
|
||||
|
||||
/**
|
||||
* 只写
|
||||
*/
|
||||
WRITE("write-only"),
|
||||
|
||||
/**
|
||||
* 读写
|
||||
*/
|
||||
READ_WRITE("read-write");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final String type;
|
||||
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package org.ruoyi.common.oss.enumd;
|
||||
package org.ruoyi.common.oss.enums;
|
||||
|
||||
import com.amazonaws.services.s3.model.CannedAccessControlList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import software.amazon.awssdk.services.s3.model.BucketCannedACL;
|
||||
import software.amazon.awssdk.services.s3.model.ObjectCannedACL;
|
||||
|
||||
/**
|
||||
* 桶访问策略配置
|
||||
@@ -16,32 +17,32 @@ public enum AccessPolicyType {
|
||||
/**
|
||||
* private
|
||||
*/
|
||||
PRIVATE("0", CannedAccessControlList.Private, PolicyType.WRITE),
|
||||
PRIVATE("0", BucketCannedACL.PRIVATE, ObjectCannedACL.PRIVATE),
|
||||
|
||||
/**
|
||||
* public
|
||||
*/
|
||||
PUBLIC("1", CannedAccessControlList.PublicRead, PolicyType.READ),
|
||||
PUBLIC("1", BucketCannedACL.PUBLIC_READ_WRITE, ObjectCannedACL.PUBLIC_READ_WRITE),
|
||||
|
||||
/**
|
||||
* custom
|
||||
*/
|
||||
CUSTOM("2", CannedAccessControlList.PublicRead, PolicyType.READ);
|
||||
CUSTOM("2", BucketCannedACL.PUBLIC_READ, ObjectCannedACL.PUBLIC_READ);
|
||||
|
||||
/**
|
||||
* 桶 权限类型
|
||||
* 桶 权限类型(数据库值)
|
||||
*/
|
||||
private final String type;
|
||||
|
||||
/**
|
||||
* 文件对象 权限类型
|
||||
* 桶 权限类型
|
||||
*/
|
||||
private final CannedAccessControlList acl;
|
||||
private final BucketCannedACL bucketCannedACL;
|
||||
|
||||
/**
|
||||
* 桶策略类型
|
||||
* 文件对象 权限类型
|
||||
*/
|
||||
private final PolicyType policyType;
|
||||
private final ObjectCannedACL objectCannedACL;
|
||||
|
||||
public static AccessPolicyType getByType(String type) {
|
||||
for (AccessPolicyType value : values()) {
|
||||
@@ -13,6 +13,7 @@ import org.ruoyi.common.redis.utils.RedisUtils;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/**
|
||||
* 文件上传Factory
|
||||
@@ -23,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class OssFactory {
|
||||
|
||||
private static final Map<String, OssClient> CLIENT_CACHE = new ConcurrentHashMap<>();
|
||||
private static final ReentrantLock LOCK = new ReentrantLock();
|
||||
|
||||
/**
|
||||
* 获取默认实例
|
||||
@@ -45,17 +47,25 @@ public class OssFactory {
|
||||
throw new OssException("系统异常, '" + configKey + "'配置信息不存在!");
|
||||
}
|
||||
OssProperties properties = JsonUtils.parseObject(json, OssProperties.class);
|
||||
OssClient client = CLIENT_CACHE.get(configKey);
|
||||
if (client == null) {
|
||||
CLIENT_CACHE.put(configKey, new OssClient(configKey, properties));
|
||||
log.info("创建OSS实例 key => {}", configKey);
|
||||
return CLIENT_CACHE.get(configKey);
|
||||
// 使用租户标识避免多个租户相同key实例覆盖
|
||||
String key = configKey;
|
||||
if (StringUtils.isNotBlank(properties.getTenantId())) {
|
||||
key = properties.getTenantId() + ":" + configKey;
|
||||
}
|
||||
// 配置不相同则重新构建
|
||||
if (!client.checkPropertiesSame(properties)) {
|
||||
CLIENT_CACHE.put(configKey, new OssClient(configKey, properties));
|
||||
log.info("重载OSS实例 key => {}", configKey);
|
||||
return CLIENT_CACHE.get(configKey);
|
||||
OssClient client = CLIENT_CACHE.get(key);
|
||||
// 客户端不存在或配置不相同则重新构建
|
||||
if (client == null || !client.checkPropertiesSame(properties)) {
|
||||
LOCK.lock();
|
||||
try {
|
||||
client = CLIENT_CACHE.get(key);
|
||||
if (client == null || !client.checkPropertiesSame(properties)) {
|
||||
CLIENT_CACHE.put(key, new OssClient(configKey, properties));
|
||||
log.info("创建OSS实例 key => {}", configKey);
|
||||
return CLIENT_CACHE.get(key);
|
||||
}
|
||||
} finally {
|
||||
LOCK.unlock();
|
||||
}
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@ import lombok.Data;
|
||||
@Data
|
||||
public class OssProperties {
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 访问站点
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user