Xiajijian
2026-03-16 0ab71d4f9154dc2a0306ea57ec08659f4e28e449
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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();
//    }
}