目前很多小伙伴提到 Minio 版本升级问题,一下为批改办法:
依赖批改
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.0.3</version>
</dependency>
类增加如下 import 内容
import io.minio.*;
次要问题如下:
1.MinioClient 的构造函数形式变为从 builder 里获取
批改前:MinioClient minioClient = new MinioClient(minioUrl, minioName,minioPass);
批改后:MinioClient.builder().endpoint(minioUrl)
.credentials(minioName, minioPass)
.build();
2. 查看桶的存在
批改前:boolean isExist = minioClient.bucketExists(bucketName);
批改后:boolean isExist = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build()
3. 创立桶的形式
批改前:minioClient.makeBucket(newBucket);
批改后:minioClient.makeBucket(MakeBucketArgs.builder().bucket(newBucket).build());
4. 文件上传形式
批改前:minioClient.putObject(newBucket,objectName, stream,stream.available(),"application/octet-stream");
批改后:PutObjectArgs objectArgs = PutObjectArgs.builder().object(objectName)
.bucket(newBucket)
.contentType("application/octet-stream")
.stream(stream,stream.available(),-1).build();
minioClient.putObject(objectArgs);
5. 获取文件流
批改前:inputStream =minioClient.getObject(bucketName, objectName);
批改后:GetObjectArgs objectArgs = GetObjectArgs.builder().object(objectName)
.bucket(bucketName).build();
inputStream = minioClient.getObject(objectArgs);
6. 删除文件
批改前:minioClient.removeObject(bucketName, objectName);
批改后:RemoveObjectArgs objectArgs = RemoveObjectArgs.builder().object(objectName)
.bucket(bucketName).build();
minioClient.removeObject(objectArgs);
如有小伙伴也遇到了雷同的问题,并批改了其余相干的中央,能够分割小弟一起学习探讨