package com.rongyichuang.config;
|
|
import com.qcloud.cos.COSClient;
|
import com.qcloud.cos.ClientConfig;
|
import com.qcloud.cos.auth.BasicCOSCredentials;
|
import com.qcloud.cos.auth.COSCredentials;
|
import com.qcloud.cos.region.Region;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
|
/**
|
* 腾讯云COS配置
|
*/
|
@Configuration
|
public class CosConfig {
|
|
@Value("${cos.secret-id}")
|
private String secretId;
|
|
@Value("${cos.secret-key}")
|
private String secretKey;
|
|
@Value("${cos.region}")
|
private String region;
|
|
@Bean
|
public COSClient cosClient() {
|
COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
|
Region regionObj = new Region(region);
|
ClientConfig clientConfig = new ClientConfig(regionObj);
|
return new COSClient(cred, clientConfig);
|
}
|
}
|