一个封装了文件存储的框架,支持本地磁盘、阿里云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代码<dependency>
<groupId>io.github.jqdi</groupId>
<artifactId>file-storage-spring-boot-starter</artifactId>
<version>{latest.version}</version>
</dependency>
{latest.version}可通过中央仓库查询
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.18.5</version>
</dependency>
filestorage:
active: alioss
alioss:
endpoint: oss-cn-shenzhen.aliyuncs.com
accessKey: LTAIkcl2bVhsEpGf
secretKey: D9hwgRig2IKQ6rIE4PBUglmKsqTpUm
bucketName: buket-test
durationSeconds: 3600
@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 信息。
- 联系作者 897665787@qq.com