Skip to content

weimin96/oss-spring-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OSS Spring Starter

Java CI Coverage Status Maven central License Last Commit

README: English | 中文

Wiki: Wiki

Introduction

This project mainly utilizes the mainstream OSS object storage services (Tencent Cloud OSS / Alibaba Cloud OSS / Huawei Cloud OBS / Qiniu Cloud / MinIo) that are compatible with Amazon S3 (Simple Storage Service) protocol. It provides a series of object storage operations based on the automated configuration feature of Spring Boot.

Features

  • Support: Tencent Cloud, Alibaba Cloud, Huawei Cloud, Qiniu Cloud, JD Cloud, MinIo
  • Provide a series of basic web endpoints and swagger documentation, supporting freedom to enable
    • Provides large file chunk uploading
    • Provides file preview
    • ......
  • Support cross-service file transfer ossTemplate.put().transferObject()
  • Provide bucket cross-origin configuration oss.cross=true

Version Basics

  • JDK 1.8
  • Spring Boot 2.x

How to Use

Add Dependencies

  • Add the following dependency in your Maven project:
<dependency>
    <groupId>io.github.weimin96</groupId>
    <artifactId>oss-spring-starter</artifactId>
    <version>${lastVersion}</version>
</dependency>
  • Add the following dependency in your Gradle project:
dependencies {
  implementation 'io.github.weimin96:oss-spring-starter:${lastVersion}'
}
  • Or add the following configuration in application.yml:
oss:
  endpoint: https://xxx.com
  access-key: YOUR_ACCESS_KEY
  secret-key: YOUR_SECRET_KEY
  bucket-name: your-bucket-name
  enable: true
  • Code Usage
@Autowired
private OssTemplate template;

// upload file
ossTemplate.put().putObject("bucket", "1.jpg", new File("/data/1.jpg"));

Parameter Configuration

Explanation of all configurations:

Configuration Type Default Value Description
oss.enable boolean false Enable OSS or not
oss.endpoint String Endpoint of the OSS service
oss.bucket-name String Bucket name
oss.access-key String Access key ID
oss.secret-key String Access secret key
oss.cross boolean false Allow cross-origin or not
oss.type String OSS type (options: obs/minio)
oss.max-connections int 50 max connections
oss.connection-timeout int 10000 connection timeout
oss.http.prefix String Prefix of the endpoint URL
oss.http.enable boolean false Enable web endpoints or not

About

oss-spring-starter is a toolkit based on Spring Boot and Amazon S3. With this toolkit, you can easily perform operations related to OSS (Object Storage Service) storage.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages