package com.vctgo.file.config;

import com.vctgo.file.domain.MinioInfo;
import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(MinioInfo.class)
public class MinioConfig {

    @Autowired
    private MinioInfo minioInfo;

    /**
     * 获取 MinioClient
     */
    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder().endpoint(minioInfo.getUrl())
                .credentials(minioInfo.getAccesskey(),minioInfo.getSecretkey())
                .build();
    }
}