Python Package

minio

2023-03-25

minio 是 [[MinIO]][[Python]] 客户端库,

安装

Terminal window
1
pip3 install minio

使用

1
from minio import Minio
2
3
# 创建 Minio 客户端
4
5
client = Minio("play.min.io",
6
access_key="Q3AM3UQ867SPQQA43P2F",
7
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
8
)

按目录删除

1
from minio import Minio
2
from minio.deleteobjects import DeleteObject
3
4
delete_object_list = map(
5
lambda x: DeleteObject(x.object_name),
6
client.list_objects("my-bucket", "my/prefix/", recursive=True),
7
)
8
errors = client.remove_objects("my-bucket", delete_object_list)
9
for error in errors:
10
print("error occured when deleting object", error)

最后循环的时候才会实际执行删除操作。

参考