Skip to content

Getting Started with oss spring starter

aoliao edited this page Aug 27, 2023 · 1 revision

如何使用

引入依赖

  • 使用 Maven 添加依赖项:
<dependency>
    <groupId>io.github.weimin96</groupId>
    <artifactId>oss-spring-starter</artifactId>
    <version>${lastVersion}</version>
</dependency>
  • 或者使用 Gradle 添加依赖项:
dependencies {
  implementation 'io.github.weimin96:oss-spring-starter:${lastVersion}'
}
  • application.yml 添加配置
oss:
  endpoint: https://xxx.com
  access-key: YOUR_ACCESS_KEY
  secret-key: YOUR_SECRET_KEY
  bucket-name: your-bucket-name
  • 代码使用
@Autowired
private OssTemplate template;

// 上传文件
ossTemplate.put().putObject("bucket", "1.jpg", new File("/data/1.jpg"));