Coder Social home page Coder Social logo

oss-spring-boot-starter's Introduction

oss-spring-boot-starter

兼容 S3 协议的通用对象存储工具类 ,理论上支持所有兼容 S3 协议的对象存储

  • MINIO
  • 阿里云
  • 华为云
  • 腾讯云
  • 七牛云

...

使用方法

未上传 maven 仓库,可 clone 后使用

clone 项目

git clone [email protected]:stream1080/oss-spring-boot-starter.git
cd oss-spring-boot-starter
mvn clean install

引入依赖

<dependency>
  <groupId>com.stream1080.plugin</groupId>
  <artifactId>oss-spring-boot-starter</artifactId>
  <version>${version}</version>
</dependency>

配置文件

oss:
  http:
    enable: true  # 开启 http 操作端点
    prefix: minio # url 前缀,默认为空
  endpoint: http:127.0.0.1:9000
  access-key: xxxxxx
  secret-key: xxxxxx

代码使用

@RestController
public class OssTest {

  @Autowired
  private OssTemplate ossTemplate;

  /**
   * 上传文件
   *
   * @param file       文件对象
   * @param bucketName bucket 名称
   * @param filename   文件名
   * @return
   * @throws IOException IOException
   */
  @PostMapping("/upload")
  public R upload(@RequestParam("file") MultipartFile file, String bucketName, String filename) throws IOException {
    ossTemplate.putObject(bucketName, filename, file.getInputStream());
    return ResponseVo.ok();
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.