'Download entire directory in a bucket of MinIO
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?
Solution 1:[1]
If you simply need to download the files use minio client copy. mc cp (source) (destination) --recursive
Solution 2:[2]
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.
Solution 3:[3]
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
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 | AshithR |
| Solution 2 | wisn |
| Solution 3 | motad333 |
