minio 图片存储自用封装
> minio windows 网盘地址附 傻瓜.bat启动 提取码:1269
linux 配置方式与windows 基本一致,除了要下载的minio文件不一样以外
<!--maven 依赖-->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.0.3</version>
</dependency>
minio文件上传util
/**
* <P>文件工具类</P>
*
* @author Administrator 武辰
* @date 2020/10/23 15:54
*/
@Slf4j
@Component
@PropertySource("classpath:minioconfig.properties")
public class FileUtil {
@Value("${minio.fileUploadUrl}")
private String fileUploadUrl;
@Value("${minio.accessKey}")
private String accessKey;
@Value("${minio.secretKey}")
private String secretKey;
/*@Value("${minio.localPath}")
private String localPath;*/ //桶服务器的本地路径 自己启动时配置
@Value("${minio.bucketName}")
private String bucketName;
public String fileUpload(InputStream inputStream, String filename, String contentType) {
try {
MinioClient build = new MinioClient.Builder().endpoint(fileUploadUrl)
.credentials(accessKey, secretKey)
.build();
String policy = "{\n" +
" \"Statement\": [\n" +
" {\n" +
" \"Action\": [\n" +
" \"s3:GetBucketLocation\",\n" +
" \"s3:ListBucket\"\n" +
" ],\n" +
" \"Effect\": \"Allow\",\n" +
" \"Principal\": \"*\",\n" +
" \"Resource\": \"arn:aws:s3:::" + bucketName + "\"\n" +