package com.brframework.commonoss.config; import com.brframework.commonoss.core.AliYunOSSClient; import com.brframework.commonoss.core.AliYunOSSClientBuilder; import com.brframework.commonoss.core.sts.AliYunSTSClient; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * 对象存储配置 * @author xu * @date 2019/8/21 10:22 */ @Configuration @ConfigurationProperties("oss.aliyun") @Data public class AliYunSTSConfig { // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。 private String accessKeyId; private String accessKeySecret; private String roleArn; private String roleSessionName; private Long stsDurationSeconds; @Bean public AliYunSTSClient stsClient(){ // 创建STS实例。 return new AliYunSTSClient(accessKeyId, accessKeySecret, roleArn, roleSessionName, stsDurationSeconds); } }