An open API service indexing awesome lists of open source software.

https://github.com/lkqm/aliyun-oss-spring-boot-starter

Aliyun oss spring boot starter.
https://github.com/lkqm/aliyun-oss-spring-boot-starter

Last synced: about 2 months ago
JSON representation

Aliyun oss spring boot starter.

Awesome Lists containing this project

README

        

# aliyun-oss-spring-boot-starter

Aliyun oss spring boot starter.

Supports: JDK 1.7, spring-boot 1.5.x, spring-boot 2.x

## Features
- Spring Boot快速接入阿里云oss.
- 支持默认bucket、内网请求、自定义域名、多种认证方式.
- 提供模版操作类`AliyunOssTemplate`方便上传/下载等.

## Quick
1. 添加依赖
```

com.github.lkqm
aliyun-oss-spring-boot-starter
1.0.2

```

2. 配置(application.properties)
```
aliyun.oss.endpoint=@endpoint # 阿里云服务地址(必)
aliyun.oss.internal-endpoint=@internalEndpoint # 阿里云服务地址内网, 配置后上传下载会使用, 不影响返回的url地址
aliyun.oss.region-id=@regionId # 地区标识, 当role-arn不为空,必填

aliyun.oss.access-key-id=@keyId # 访问key(必)
aliyun.oss.access-key-secret=@secret # 访问密钥(必)
aliyun.oss.security-token=@token # token
aliyun.oss.role-arn=@roleArn # STS授权角色,如果不为空将使用STS构建OSS

aliyun.oss.bucket=@bucket # 默认上传的空间(必)
aliyun.oss.bucket-custom-domain.@bucket=@domain # 配置自定义域名

aliyun.oss.config.XXX=@xxx # 更多客户端配置, 参看: `ClientBuilderConfiguration`
```

3. 注入使用
```
@Resource
AliyunOssTemplate aliyunOssTemplate;

@Resource
OSS aliyunOssClient;

@Test
public void test() {
String url = aliyunOssTemplate.uploadFileText("test/hello.txt", "hello world!");
System.out.println(url);
}
```