'How to download all files from MinIO bucket in python by only using bucket name .....& no file name

I need to download all the files from the MinIO bucket into the certain local folder Dir. But, I do not have the names of the files which is inside that bucket.



Solution 1:[1]

even if don`t have name of bucket u can use bellow:

client = Minio(
    "storage_address",
    access_key="XXXXXXXXXXXXXXXXX",
    secret_key="XXXXXXXXXXXXXXXXXXXXXXXXXXX",
)

for bucket in client.list_buckets():
    for item in client.list_objects(bucket.name,recursive=True):
        client.fget_object(bucket.name,item.object_name,item.object_name)

recursive=True will return all folders with files

fget_object will save files and directory as saved in minio

i u want just one special bucket u can just remove first for loop and replace bucket.name with your special bucket name

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 motad333