Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

兼容S3协议的通用文件存储工具类

License

NotificationsYou must be signed in to change notification settings

pig-mesh/oss-spring-boot-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central

兼容S3 协议的通用文件存储工具类 ,支持 兼容S3 协议的云存储

  • MINIO
  • 阿里云
  • 华为云
  • 腾讯云
  • 京东云

...

spring boot starter依赖

版本支持
3.1.1适配 SpringBoot3.x
1.0.5适配 SpringBoot2.x
  • 方便在 web 环境下使用oss ,已上传至 maven 仓库
<dependency>    <groupId>com.pig4cloud.plugin</groupId>    <artifactId>oss-spring-boot-starter</artifactId>    <version>${lastVersion}</version></dependency>

使用方法

配置文件

  • MINIO 示例
oss:endpoint:http://minio.pig4cloud.comaccess-key:lenglengsecret-key:lengleng
  • 阿里云 示例
oss:endpoint:https://oss-cn-beijing.aliyuncs.comaccess-key:xxxsecret-key:xxxpath-style-access:false# 阿里云需要关闭  Please use virtual hosted style to access

代码使用

@AutowiredprivateOssTemplatetemplate;/** * 上传文件 * 文件名采用uuid,避免原始文件名中带"-"符号导致下载的时候解析出现异常 * * @param file 资源 * @return R(bucketName, filename) */@PostMapping("/upload")publicRupload(@RequestParam("file")MultipartFilefile,HttpServletRequestrequest) {template.putObject(CommonConstants.BUCKET_NAME,fileName,file.getInputStream());returnR.ok(resultMap);}

About

兼容S3协议的通用文件存储工具类

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors10

Languages


[8]ページ先頭

©2009-2025 Movatter.jp