package com.ruoyi.storage.minio.utils;
|
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.stereotype.Component;
|
|
/**
|
* @Description:
|
* @ClassName: MinioClientSingleton
|
* @Author: 刘苏义
|
* @Date: 2023年05月18日9:32
|
* @Version: 1.0
|
**/
|
@Slf4j(topic = "minio")
|
@Component
|
public class MinioConfig {
|
@Value("${minio.endpoint}")
|
private String endpoint;
|
@Value("${minio.accessKey}")
|
private String accessKey;
|
@Value("${minio.secretKey}")
|
private String secretKey;
|
|
// private volatile static MinioClient minioClient;
|
|
@Bean
|
public io.minio.MinioClient getMinioClient() {
|
return io.minio.MinioClient.builder()
|
.endpoint(endpoint)
|
.credentials(accessKey, secretKey)
|
.build();
|
}
|
|
// /**
|
// * 获取minio客户端实例
|
// *
|
// * @return {@link MinioClient}
|
// */
|
// public static MinioClient getMinioClient() {
|
// if (minioClient == null) {
|
// synchronized (MinioClientSingleton.class) {
|
// if (minioClient == null) {
|
// minioClient = MinioClient.builder()
|
// .endpoint(endpoint)
|
// .credentials(accessKey, secretKey)
|
// .build();
|
// }
|
// }
|
// }
|
// return minioClient;
|
// }
|
// static {
|
// domainUrl = getYmlNew("minio.endpoint");
|
// accessKey = getYmlNew("minio.accessKey");
|
// secretKey = getYmlNew("minio.secretKey");
|
// log.debug("minio信息:" + domainUrl + "(" + accessKey + "/" + secretKey + ")");
|
// }
|
/*yml配置信息获取*/
|
// public static String getYmlNew(String key) {
|
// Resource resource = new ClassPathResource("application-prod.yml");
|
// Properties properties = null;
|
// try {
|
// YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean();
|
// yamlFactory.setResources(resource);
|
// properties = yamlFactory.getObject();
|
// } catch (Exception e) {
|
// e.printStackTrace();
|
// return null;
|
// }
|
// return properties.get(key).toString();
|
// }
|
|
}
|