init
This commit is contained in:
parent
8a6f6a055b
commit
306eb37b5b
@ -8,7 +8,7 @@ spring:
|
||||
master:
|
||||
url: jdbc:mysql://127.0.0.1/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: WKY20031018
|
||||
password: 123456
|
||||
# 从库数据源
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
|
@ -30,6 +30,6 @@ minio:
|
||||
client:
|
||||
master:
|
||||
url: http://localhost:9000
|
||||
accessKey: root
|
||||
secretKey: wky20031018
|
||||
defaultBuket: bim-model
|
||||
accessKey:
|
||||
secretKey:
|
||||
defaultBuket: ruoyi
|
||||
|
@ -12,7 +12,7 @@ ruoyi:
|
||||
addressEnabled: false
|
||||
# 验证码类型 math 数组计算 char 字符验证
|
||||
captchaType: math
|
||||
|
||||
# 指定文件服务类型(值为disk代表使用磁盘作为文件操作服务,minio代表使用minio作为文件操作服务)
|
||||
fileServer: minio
|
||||
|
||||
# 开发环境配置
|
||||
|
@ -1,10 +1,16 @@
|
||||
package com.ruoyi.middleware.minio.config;
|
||||
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.PutObjectArgs;
|
||||
import io.minio.RemoveObjectArgs;
|
||||
import io.minio.RemoveObjectsArgs;
|
||||
import io.minio.errors.*;
|
||||
import io.minio.messages.Bucket;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.apache.http.impl.io.EmptyInputStream;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -78,11 +84,6 @@ public class MinioConfig {
|
||||
entity.setClient(build);
|
||||
} catch (Exception exception) {
|
||||
MinioClient build = MinioClient.builder().endpoint(entity.getUrl()).build();
|
||||
try {
|
||||
build.listBuckets();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
entity.setClient(build);
|
||||
}
|
||||
}
|
||||
@ -93,16 +94,8 @@ public class MinioConfig {
|
||||
if(StringUtils.isEmpty(defaultBuket)){
|
||||
throw new RuntimeException("defaultBuket without a default value ");
|
||||
}
|
||||
List<Bucket> buckets = entity.getClient().listBuckets();
|
||||
if (buckets.isEmpty()) {
|
||||
throw new RuntimeException("minioClient without any buket");
|
||||
}
|
||||
for (Bucket bucket : buckets) {
|
||||
if (bucket.name().equals(entity.getDefaultBuket())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("configured defaultBucket does not exist");
|
||||
RemoveObjectArgs remove = RemoveObjectArgs.builder().bucket(entity.getDefaultBuket()).object("test").build();
|
||||
entity.getClient().removeObject(remove);
|
||||
}catch (Exception e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user