Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pig-mesh/oss-spring-boot-starter
兼容S3协议的通用文件存储工具类
https://github.com/pig-mesh/oss-spring-boot-starter
oss s3 s3-storage spring-boot
Last synced: 1 day ago
JSON representation
兼容S3协议的通用文件存储工具类
- Host: GitHub
- URL: https://github.com/pig-mesh/oss-spring-boot-starter
- Owner: pig-mesh
- License: other
- Created: 2020-07-15T06:07:01.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-11-06T09:15:01.000Z (3 months ago)
- Last Synced: 2025-01-13T10:02:29.277Z (8 days ago)
- Topics: oss, s3, s3-storage, spring-boot
- Language: Java
- Homepage:
- Size: 66.4 KB
- Stars: 255
- Watchers: 11
- Forks: 84
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## oss-spring-boot-starter
兼容S3 协议的通用文件存储工具类 ,支持 兼容S3 协议的云存储
- MINIO
- 阿里云
- 华为云
- 腾讯云
- 京东云...
## spring boot starter依赖
| 版本 | 支持 |
|-------|--|
| 3.0.0 | 适配 SpringBoot3.x |
| 1.0.5 | 适配 SpringBoot2.x |- 方便在 web 环境下使用 `oss` ,已上传至 maven 仓库
```xmlcom.pig4cloud.plugin
oss-spring-boot-starter
${lastVersion}```
## 使用方法
### 配置文件
```yaml
oss:
endpoint: http://minio.pig4cloud.com
access-key: lengleng
secret-key: lengleng
```### 代码使用
```java
@Autowired
private OssTemplate template;
/**
* 上传文件
* 文件名采用uuid,避免原始文件名中带"-"符号导致下载的时候解析出现异常
*
* @param file 资源
* @return R(bucketName, filename)
*/
@PostMapping("/upload")
public R upload(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
template.putObject(CommonConstants.BUCKET_NAME, fileName, file.getInputStream());
return R.ok(resultMap);
}
```