Skip to content

jqdi/file-storage

Repository files navigation

一个封装了文件存储的框架,支持本地磁盘、阿里云OSS、MinIO、亚马逊AWS、百度BOS、华为云OBS、京东云OOS、腾讯云COS、网易NOS等

平台支持

平台 支持
阿里云OSS(支持STS模式)
亚马逊AWS(支持STS模式)
百度BOS
华为云OBS
京东云OOS
本地磁盘
MinIO(支持STS模式)
腾讯云COS
网易NOS

模块说明

file-storage
├── file-storage-core -- 核心代码
	 └── alioss -- 阿里云OSS
	 └── amazons3 -- 亚马逊AWS
	 └── baidubos -- 百度BOS
	 └── huaweiobs -- 华为云OBS
	 └── jingdongoss -- 京东云OOS
	 └── local -- 本地磁盘
	 └── minio -- MinIO
	 └── tencentcos -- 腾讯云COS
	 └── wangyinos -- 网易NOS
└── file-storage-boot-starter -- 整合springboot代码
└── file-storage-springboot-demo -- 在springboot中使用file-storage的demo代码

使用说明

1:file-storage已发布至maven中央仓库,可以直接引入到项目中,maven依赖如下:

<dependency>
    <groupId>io.github.jqdi</groupId>
    <artifactId>file-storage-spring-boot-starter</artifactId>
    <version>{latest.version}</version>
</dependency>

{latest.version}可通过中央仓库查询

2:如使用阿里云OSS,需引入阿里云sdk,其他可参考file-storage-core的pom配置

<dependency>
    <groupId>com.aliyun.oss</groupId>
    <artifactId>aliyun-sdk-oss</artifactId>
    <version>3.18.5</version>
</dependency>

3:springboot yml 配置(如使用阿里云OSS),其他可参考file-storage-springboot-demo的pom配置

filestorage:
  active: alioss
  alioss:
    endpoint: oss-cn-shenzhen.aliyuncs.com
    accessKey: LTAIkcl2bVhsEpGf
    secretKey: D9hwgRig2IKQ6rIE4PBUglmKsqTpUm
    bucketName: buket-test
    durationSeconds: 3600

4:在代码中使用

@Autowired
private FileStorage fileStorage;

public String upload(InputStream inputStream, String basePath, String fileName) {
    String fileKey = generateFileKey(basePath, fileName);
    fileStorage.upload(inputStream, fileKey);
    return fileKey;
}

public String presignedUrl(String fileKey) {
    return fileStorage.presignedUrl(fileKey);
}

开源共建

开源协议

file-storage 开源软件遵循 Apache 2.0 协议。 允许商业使用,但务必保留类作者、Copyright 信息。

其他说明

  1. 联系作者 897665787@qq.com

About

一个封装了文件存储的框架,支持本地磁盘、阿里云OSS、MinIO、亚马逊AWS、百度BOS、华为云OBS、京东云OOS、腾讯云COS、网易NOS等

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages