package cn.pluss.platform.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.OSSClientBuilder;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.Scope;

@Data
@Configuration
@PropertySource("classpath:config/application-common.yml")
public class OssConfig {

    @Value("${aliyun.oss.endpoint}")
    private String endpoint;       //连接区域地址
    @Value("${aliyun.keyid}")
    private String keyid;    //连接keyId
    @Value("${aliyun.keysecret}")
    private String keysecret;    //连接秘钥
    @Value("${aliyun.oss.bucketname}")
    private String bucketname;     //需要存储的bucketName
    @Value("${aliyun.region-id}")
    private String regionId;
    @Value("${aliyun.oss.callback}")
    private String callback;

    @Bean
    @Scope("prototype")
    public OSS ossClient(){
        return new OSSClientBuilder().build(endpoint, keyid, keysecret);
    }
}
