# 华为云OBS

# 核心配置

# Yaml配置

# ========================= HaiChuang Settings =========================
haichuang:
  sdk:
    huaweicloudobs:
      # AccessKeyId
      access-key-id: xxx
      # AccessKeySecret
      access-key-secret: xxx
      # BucketName
      bucket-name: xxx
      # Endpoint地域节点
      endpoint: xxx
1
2
3
4
5
6
7
8
9
10
11
12

提示

可通过HuaWeiCloudObsProperties (opens new window) 中的getBucketDomain()方法获取BucketDomain(访问域名前缀)

@Autowired
private HuaWeiCloudObsProperties huaWeiCloudObsProperties;

@Test
void getBucketDomain() {
    System.out.println(huaWeiCloudObsProperties.getBucketDomain());
}
1
2
3
4
5
6
7

# 核心注解

包路径:pro.haichuang.framework.sdk.huaweicloudobs.annotation (opens new window)

# @EnableObsUrlConvert (opens new window)

  • 注解名称:启用华为云OBS地址转换
  • 实现功能:该注解标注在Controller方法上,代表该方法启用OBS地址解析,该注解与@ObsUrl一起使用
  • 标注位置:Controller方法上

# @ObsUrl (opens new window)

  • 注解名称:华为云OBS地址转换
  • 实现功能:该注解标注在Controller方法形参上或实体内, 将会在请求时自动去掉OBS请求前缀, 在响应时自动添加OBS请求前缀
  • 标注位置:指定方法形参或类字段上
  • 使用方法:
    1. Controller方法上标注@EnableObsUrlConvert注解
    2. 在形参对象类中标注@ObsUrl注解

# 核心Service

# HuaWeiCloudObsService (opens new window)

全限定名:pro.haichuang.framework.sdk.huaweicloudobs.service.HuaWeiCloudObsService (opens new window)

华为云OBS核心Service

该类为华为云OBS核心Service,封装了常用的方法

警告

所有OBS相关操作必须使用HuaWeiCloudObsService接口

# DefaultHuaWeiCloudObsServiceImpl (opens new window)

全限定名:pro.haichuang.framework.sdk.huaweicloudobs.service.DefaultHuaWeiCloudObsServiceImpl (opens new window)

华为云OBS核心Service默认实现

该类为华为云OBS核心Service默认实现,已默认注入到Spring中,支持自定义实现(需要手动注入到Spring中)

# 核心工具类

# HuaWeiCloudObsUtils (opens new window)

全限定名:pro.haichuang.framework.sdk.huaweicloudobs.util.HuaWeiCloudObsUtils (opens new window)

华为云OBS工具类

该类为华为云OBS工具类,基于第三方二次封装,推荐使用HuaWeiCloudObsService进行操作

# 👇Example👇

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private HuaWeiCloudObsService aliYunObsService;
    
    ......
}
1
2
3
4
5
6
7
8
9
Last Updated: 12/14/2021, 5:11:19 PM