java 如何在Sping Boot 应用中删除MinIO中的多个文件?

w8ntj3qf  于 2023-06-28  发布在  Java
关注(0)|答案(1)|浏览(350)

我有一个数据库实体,它与存储在MinIO中的许多文件相连接。如何在一次操作中删除多个文件?

qni6mghb

qni6mghb1#

如果你正在使用minioClient,你可以尝试这样做:

List<DeleteObject> objects = new LinkedList<>();
 objects.add(new DeleteObject("my-objectname1"));
 objects.add(new DeleteObject("my-objectname2"));
 objects.add(new DeleteObject("my-objectname3"));
 Iterable<Result<DeleteError>> results =
     minioClient.removeObjects(
         RemoveObjectsArgs.builder().bucket("my-bucketname").objects(objects).build());
 for (Result<DeleteError> result : results) {
   DeleteError error = errorResult.get();
   System.out.println(
       "Error in deleting object " + error.objectName() + "; " + error.message());
 }

相关问题