Python Package

minio

2023-03-25

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

安装

Terminal window
pip3 install minio

使用

from minio import Minio
# 创建 Minio 客户端
client = Minio("play.min.io",
access_key="Q3AM3UQ867SPQQA43P2F",
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
)

按目录删除

from minio import Minio
from minio.deleteobjects import DeleteObject
delete_object_list = map(
lambda x: DeleteObject(x.object_name),
client.list_objects("my-bucket", "my/prefix/", recursive=True),
)
errors = client.remove_objects("my-bucket", delete_object_list)
for error in errors:
print("error occured when deleting object", error)

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

参考