package com.ard.sample.config;
|
|
import com.ard.oss.model.enums.OssTypeEnum;
|
import io.minio.MinioClient;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.stereotype.Component;
|
|
@Component
|
@ConfigurationProperties(prefix = "dock")
|
public class DockConfiguration {
|
// public static String endpoint;
|
//
|
// public static String bucket;
|
//
|
// public void setEndpoint(String endpoint) {
|
// DockConfiguration.endpoint = endpoint;
|
// }
|
//
|
// public void setBucket(String bucket) {
|
// DockConfiguration.bucket = bucket;
|
// }
|
/**
|
* @see OssTypeEnum
|
*/
|
public static String provider;
|
|
/**
|
* Whether to use the object storage service.
|
*/
|
public static boolean enable;
|
|
/**
|
* The protocol needs to be included at the beginning of the address.
|
*/
|
public static String endpoint;
|
|
public static String accessKey;
|
|
public static String secretKey;
|
|
public static String region;
|
|
public static Long expire;
|
|
public static String roleSessionName;
|
|
public static String roleArn;
|
|
public static String bucket;
|
|
public static String objectDirPrefix;
|
|
public void setProvider(String provider) {
|
DockConfiguration.provider = provider;
|
}
|
|
public void setEnable(boolean enable) {
|
DockConfiguration.enable = enable;
|
}
|
|
public void setEndpoint(String endpoint) { DockConfiguration.endpoint = endpoint; }
|
|
public void setAccessKey(String accessKey) {
|
DockConfiguration.accessKey = accessKey;
|
}
|
|
public void setSecretKey(String secretKey) {
|
DockConfiguration.secretKey = secretKey;
|
}
|
|
public void setRegion(String region) {
|
DockConfiguration.region = region;
|
}
|
|
public void setExpire(Long expire) {
|
DockConfiguration.expire = expire;
|
}
|
|
public void setRoleSessionName(String roleSessionName) {
|
DockConfiguration.roleSessionName = roleSessionName;
|
}
|
|
public void setRoleArn(String roleArn) {
|
DockConfiguration.roleArn = roleArn;
|
}
|
|
public void setBucket(String bucket) {
|
DockConfiguration.bucket = bucket;
|
}
|
|
public void setObjectDirPrefix(String objectDirPrefix) {
|
DockConfiguration.objectDirPrefix = objectDirPrefix;
|
}
|
|
// /**
|
// * 创建MinioClient Bean(核心:适配反向代理的HTTP地址)
|
// */
|
// @Bean
|
// public MinioClient minioClient() {
|
// // 方式1:通过endpoint重载方法(推荐,明确指定端口和是否HTTPS)
|
// // 解析endpoint的协议、IP、端口
|
// String[] endpointParts = endpoint.split("//")[1].split(":");
|
// String host = endpointParts[0]; // 192.168.10.103
|
// int port = Integer.parseInt(endpointParts[1]); // 9011
|
// boolean isHttps = endpoint.startsWith("https"); // 反向代理是HTTP,故为false
|
//
|
// return MinioClient.builder()
|
// .endpoint(host, port, isHttps) // 8.3.7核心:通过重载方法指定secure
|
// .credentials(accessKey, secretKey)
|
// .build();
|
// }
|
}
|