JeecgBoot Minio版本6.0.13升級到8.0.3修改方法
阿新 • • 發佈:2021-06-30
寫的全面,轉載一下:https://segmentfault.com/a/1190000039370475
依賴修改
<dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> <version>8.0.3</version> </dependency>
類新增如下import內容
import io.minio.*;
主要問題如下:
修改前: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);
如有小夥伴也遇到了相同的問題,並修改了其他相關的地方,可以聯絡小弟一起學習探討