package com.keystar.plane.inspection.config;

import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Data
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinIoConfig {
    @Value("${minio.addr}")
    private String addr;
    @Value("${minio.accessKey}")
    private String accessKey;
    @Value("${minio.secretKey}")
    private String secretKey;
    @Value("${minio.expires}")
    private int expires;

    @Value("${minio.bucket.name:nest}")
    private String bucketName;

    @Value("${minio.resourcePath}")
    private String resourcePath;


    @Bean
    public MinioClient minioClient() throws InvalidPortException, InvalidEndpointException {
        return new MinioClient("http://" + addr, accessKey, secretKey);
    }
}
