文字转语音
This commit is contained in:
73
src/main/java/com/rj/config/MinIOConfig.java
Normal file
73
src/main/java/com/rj/config/MinIOConfig.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.rj.config;
|
||||
|
||||
import io.minio.MinioClient;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* MinIO 配置类
|
||||
*
|
||||
* @author rj
|
||||
* @date 2025-10-02
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "minio")
|
||||
public class MinIOConfig {
|
||||
|
||||
/**
|
||||
* MinIO服务器地址
|
||||
*/
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
* 访问密钥
|
||||
*/
|
||||
private String accessKey;
|
||||
|
||||
/**
|
||||
* 秘密密钥
|
||||
*/
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
* 默认存储桶名称
|
||||
*/
|
||||
private String bucketName;
|
||||
|
||||
|
||||
/**
|
||||
* 创建MinIO客户端Bean
|
||||
*/
|
||||
@Bean
|
||||
public MinioClient minioClient() {
|
||||
// 验证必要的配置项
|
||||
if (!StringUtils.hasText(endpoint)) {
|
||||
throw new IllegalArgumentException("MinIO endpoint 配置不能为空,请在配置文件中设置 minio.endpoint");
|
||||
}
|
||||
if (!StringUtils.hasText(accessKey)) {
|
||||
throw new IllegalArgumentException("MinIO accessKey 配置不能为空,请在配置文件中设置 minio.access-key");
|
||||
}
|
||||
if (!StringUtils.hasText(secretKey)) {
|
||||
throw new IllegalArgumentException("MinIO secretKey 配置不能为空,请在配置文件中设置 minio.secret-key");
|
||||
}
|
||||
if (!StringUtils.hasText(bucketName)) {
|
||||
throw new IllegalArgumentException("MinIO bucketName 配置不能为空,请在配置文件中设置 minio.bucket-name");
|
||||
}
|
||||
|
||||
return MinioClient.builder()
|
||||
.endpoint(endpoint)
|
||||
.credentials(accessKey, secretKey)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件访问URL前缀
|
||||
*/
|
||||
public String getFileUrlPrefix() {
|
||||
return endpoint + "/" + bucketName + "/";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user