一、安装s3环境
1.1 minio介绍
Minio是GlusterFS创始人之一Anand Babu Periasamy发布新的开源项目。Minio兼容Amason的S3分布式对象存储项目,采用Golang实现,客户端支持Java,Python,Javacript, Golang语言
1.2 中文文档
Minio中文文档: Minio中文文档.
二、下载s3 brower测试连接
s3 brower: s3 brower.  
三、SpringBoot整合S3存储
3.1 引入sdk
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.12.38</version>
</dependency>
3.2 配置yml文件
s3:
storage:
accessKeyId: minioadmin
secretAccessKey: minioadmin
endpoint: 10.2.20.39:9090
bucketName: test
server:
port: 8081
spring:
servlet:
multipart:
max-file-size: 1000MB
max-request-size: 1000MB
3.3 AWS S3 官方最新文档
AWS S3 : AWS S3 .
3.4 主要代码逻辑
@Override
public List<FileInfo> uploadFile(MultipartFile[] files){
List<FileInfo> fileInfos = new ArrayList<>();
for(MultipartFile file : files){
if(!file.isEmpty()){
FileInfo fileInfo = new FileInfo();
fileInfo.setName(file.getOriginalFilename());
fileInfo.setSize(file.getSize());
fileInfo.setPath(getKey(fileInfo));
String id = UUID.randomUUID().toString();
fileInfo.setId(id);
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setContentLength(file.getSize());
objectMetadata.setContentType(file.getContentType());
try {
amazonS3.putObject(awsProperties.getBucketName(),getKey(fileInfo),file.getInputStream(),objectMetadata);
map.put(id,fileInfo);
} catch (IOException e) {
e.printStackTrace();
}
fileInfos.add(fileInfo);
}
}
return fileInfos;
}
3.5 测试上传

3.6 预览文件

|