package com.izouma.nineth.config;

import com.aliyun.cdn20180510.Client;
import com.aliyun.oss.OSSClient;
import com.aliyun.teaopenapi.models.Config;
import lombok.AllArgsConstructor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@AllArgsConstructor
@Configuration
@EnableConfigurationProperties(AliyunProperties.class)
public class AliyunConfig {

    private AliyunProperties aliyunProperties;

    @Bean
    public Client cdnClient() throws Exception {
        Config config = new Config()
                .setAccessKeyId(aliyunProperties.getAccessKeyId())
                .setAccessKeySecret(aliyunProperties.getAccessKeySecret());
        config.endpoint = "cdn.aliyuncs.com";
        return new Client(config);
    }
}
