# aws-s3-spring-boot-starter **Repository Path**: okmcl280/aws-s3-spring-boot-starter ## Basic Information - **Project Name**: aws-s3-spring-boot-starter - **Description**: Springboot整合AWS s3 存储,支持所有兼容 Amazon S3 的存储平台,例如移动云eos - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-02-02 - **Last Updated**: 2024-02-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: aws-s3, 移动云eos ## README **Springboot整合AWS s3 存储,支持所有兼容 Amazon S3 的存储平台,例如移动云eos** #### 一、使用 ##### 1、项目中引入依赖 ``` cn.beadata.haichao aws-s3-spring-boot-starter 1.0.1 ``` ##### 2、application.yml 配置文件中添加以下基础配置 ``` aws: endpoint: https://eos-shanghai-2.cmecloud.cn #所在地域对应的 endpoint region: shanghai2 # 以https://eos-shanghai-2.cmecloud.cn为例 bucketDomain: https://xxx.eos-shanghai-2.cmecloud.cn # 访问存储信息域名 accessKey: xxxxxxxx secretKey: xxxxxxxx bucketName: uploads #桶名 ``` ``` 对应的配置类 @Data @ConfigurationProperties(prefix = "aws") public class EOSProperties { private String endpoint = "https://eos-shanghai-2.cmecloud.cn"; private String region = "shanghai2"; private String bucketDomain = "https://xxx.eos-shanghai-2.cmecloud.cn"; private String accessKey = "xxxxxxxx"; private String secretKey = "xxxxxxxx"; private String bucketName = "uploads"; } ``` ##### 3、注入Bean(EOSTemplate)上传文件 ``` @RestController @RequestMapping("/file") @AllArgsConstructor public class FileController { private EOSTemplate eosTemplate; /** * 上传文件 */ @PostMapping("/put-file") public FileInfo putFile(@RequestParam(required = true) MultipartFile file) { return eosTemplate.uploadFile(file); } } ```