You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
Java
52 lines
1.2 KiB
Java
package com.glxp.api.config;
|
|
|
|
import io.minio.MinioClient;
|
|
import io.minio.errors.InvalidEndpointException;
|
|
import io.minio.errors.InvalidPortException;
|
|
import lombok.Data;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
//@Configuration
|
|
//@RequiredArgsConstructor
|
|
public class MinioConfig {
|
|
|
|
@Data
|
|
@ConfigurationProperties("minio")
|
|
@Configuration
|
|
public class MinioProperties {
|
|
/**
|
|
* 服务地址
|
|
*/
|
|
private String endpoint;
|
|
|
|
|
|
/**
|
|
* 用户名
|
|
*/
|
|
private String accessKey;
|
|
|
|
/**
|
|
* 密码
|
|
*/
|
|
private String secretKey;
|
|
}
|
|
|
|
|
|
/**
|
|
* 初始化客户端
|
|
*
|
|
* @return 客户端
|
|
*/
|
|
@Bean
|
|
public MinioClient minioClient(MinioProperties minioProperties) {
|
|
try {
|
|
return new MinioClient(minioProperties.getEndpoint(), minioProperties.getAccessKey(), minioProperties.getSecretKey());
|
|
} catch (InvalidEndpointException | InvalidPortException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
}
|