MinioConfig.java
1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.pashanhoo.common.minio;
import io.minio.MinioClient;
import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
/**
* @author CAIYONGSONG
* @commpany www.pashanhoo.com
* @date 2022/7/20
*/
@Data
@Component
@ConfigurationProperties(prefix = "minio")
public class MinioConfig {
private Logger log = LoggerFactory.getLogger(MinioConfig.class);
// minio地址
private String minioUrl;
//minio账号
private String accessKey;
//minio密码
private String secretKey;
//存储桶名称 */
public String bucketName;
// "如果是true,则用的是https而不是http,默认值是true"
public static Boolean secure = false;
@Bean
public MinioClient getMinioClient(){
log.info("初始化MinioClient客户端:minioUrl:" + minioUrl + ",accessKey:" + accessKey + ",secretKey:" + secretKey);
MinioClient minioClient = MinioClient.builder()
.endpoint(minioUrl)
.credentials(accessKey,secretKey)
.build();
return minioClient;
}
}