3

Here is my MinIO tree

bucket1
|
|-dir1
|-dir2
    |-file1
    |-file2
    |-file3

I want to download the entire directory "dir2" using python API.

The only way I can think of is to download files one by one. Is there another way / API call to download entire directory?

warunapww
  • 966
  • 4
  • 18
  • 38

3 Answers3

3

If you simply need to download the files use minio client copy. mc cp (source) (destination) --recursive

AshithR
  • 98
  • 1
  • 9
1

if u are using api lookelike python u can use this:

client = Minio(
    "storage_address",
    access_key="XXXXXXXXXXX",
    secret_key="XXXXXXXXXXXXXXXXXXXXXX",
)

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 open all folders and fget_object will save file with file name and folder

hn_tired
  • 690
  • 10
  • 21
0

I don't think that it is possible right now. The closest approach is to use the ComposeObject function just like on the Golang SDK API Reference. However, it is not clear that the file extension will be an archive just like ZIP or not. The most possible approach is to download the files one by one.

wisn
  • 974
  • 10
  • 17