| | |
| | | package com.ruoyi.storage.minio.utils; |
| | | |
| | | import io.minio.MinioClient; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | |
| | | @Component |
| | | public class MinioConfig { |
| | | @Value("${minio.endpoint}") |
| | | private String endpoint; |
| | | private String endpoint; |
| | | @Value("${minio.accessKey}") |
| | | private String accessKey; |
| | | private String accessKey; |
| | | @Value("${minio.secretKey}") |
| | | private String secretKey; |
| | | |
| | | // private volatile static MinioClient minioClient; |
| | | private String secretKey; |
| | | |
| | | @Bean |
| | | public io.minio.MinioClient getMinioClient() { |
| | | return io.minio.MinioClient.builder() |
| | | public MinioClient getMinioClient() { |
| | | return 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(); |
| | | // } |
| | | |
| | | } |
| | | |