package com.mosty.common.core.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *  minio配置
 * @author kevin
 * @date 2022/3/7 10:41 AM
 * @since 1.0.0
 */
@Data
@Configuration
public class MinIoClientConfig {

    @Value("${minio.endpoint:http://123.60.67.142:8001}")
    private String endpoint;
    @Value("${minio.downloadEndpoint:http://123.60.67.142:8000}")
    private String downloadEndpoint;
    @Value("${minio.accessKey:root}")
    private String accessKey;
    @Value("${minio.secretKey:sczy@2022}")
    private String secretKey;
    /** 图片桶名称 */
    @Value("${minio.bucket.image:image}")
    private String imageBucket;
    /** 文件桶名称 */
    @Value("${minio.bucket.file:file}")
    private String fileBucket;


    /**
     * 注入minio 客户端
     * @return
     */
    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                        .endpoint(endpoint)
                        .credentials(accessKey, secretKey)
                        .build();
    }
}