代码拉取完成,页面将自动刷新
opcooc-storage-spring-boot-starter 是一个基于aws s3快速集成多storage client的启动器
<dependency>
<groupId>com.opcooc</groupId>
<artifactId>opcooc-storage-spring-boot-starter</artifactId>
<version>1.2.2</version>
</dependency>
implementation 'com.opcooc:opcooc-storage-spring-boot-starter:1.2.2'
application.yml
中添加配置信息基础yaml配置。
storage:
primary: s3_minio #默认的客户端类型
strict: true #是否启用严格模式,默认不启动. 严格模式下未匹配到客户端直接报错, 非严格模式下则使用默认客户端primary所设置的客户端
enabled: true #是否开启 opcooc-storage
driver:
s3_minio: #配置文件key名称
type: S3 #默认驱动类型(默认为S3)
default-bucket: opcooc #默认主目录(需要保证唯一)
endpoint: http://xxx.com #访问域名
username: xxx #账号
password: xxx #密码
region: cn-north-1 #区域
path-style: true #路径样式(默认为true)
auto-create-bucket: true #是否自动创建目标bucket
其他yaml配置(oss, cos, kodo)。
storage:
primary: s3_minio #默认的客户端类型
strict: true #是否启用严格模式,默认不启动. 严格模式下未匹配到客户端直接报错, 非严格模式下则使用默认客户端primary所设置的客户端
enabled: true #是否开启 opcooc-storage
driver:
s3_oss:
default-bucket: opcooc
endpoint: http://oss-cn-shanghai.aliyuncs.com
username: xxx
password: xxx
path-style: false
region: cn-north-1
auto-create-bucket: true
s3_cos:
default-bucket: opcooc
endpoint: https://bucketname.cos.ap-shanghai.myqcloud.com
username: xxx
password: xxx
region: cn-north-1
auto-create-bucket: true
s3_kodo:
default-bucket: opcooc
endpoint: http://s3-cn-south-1.qiniucs.com
username: xxx
password: xxx
region: cn-north-1
auto-create-bucket: true
使用 @OS 切换客户端驱动。
@OS 可以注解在方法上或类上,同时存在就近原则 方法上注解 优先于 类上注解。
注解 | 结果 |
---|---|
没有@OS | 默认客户端驱动 |
@OS("driverName") | driverName为具体某个客户端驱动的名称 |
然后就开始玩耍吧~
@RestController
@OS("#tenantName")
@RequestMapping("/api")
@RequiredArgsConstructor
public class ClientController {
private final StorageHelper client;
@OS("#tenantName")
@PostMapping("/createFolder")
public void createFolder(@RequestParam(defaultValue = "s3_minio") String tenantName, @RequestParam String folderName) {
client.createFolder(SetFolderArgs.builder().bucketName(BUCKET_NAME).folderName(folderName).build());
}
}
对象存储 | 文件系统 |
---|---|
Object | 对象或者文件 |
Bucket | 主目录(存储空间) |
Endpoint | 访问域名 |
Region | 地域或者数据中心 |
Object Meta | 文件元信息。用来描述文件信息,例如长度,类型等 |
Data | 文件数据 |
Key | 文件名 |
ACL (Access Control List) | 存储空间或者文件的权限 |
该展示只是 opcooc-storage-spring-boot-starter 功能的一小部分。如果您想了解更多信息,请参阅项目demo项目 或 wiki: documentation.
Project |
---|
dynamic-datasource-spring-boot-starter |
opcooc-storage-spring-boot-starter is under the Apache 2.0 license. See the Apache License 2.0 file for details.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。