英文:
How to grab all files from Azure Blob and Zip them?
问题
I have an Azure Blob with multiple containers. Each container contains various folders, and each folder holds multiple files. My goal is to retrieve all the files and provide them as a compressed ZIP archive. Currently, I'm only capable of fetching one file at a time.
public void downloadAllFromBlob(String containerName){
CloudBlobClient blobClient = this.storageAccount.createCloudBlobClient();
try{
CloudBlobContainer container = blobClient.getContainerReference(containerName);
if(container.exists()){
// I aim to gather all files in the container and compress them into a ZIP
for(ListBlobItem blobItem: container.listBlobs()){
// I can only list/view the blobs, without accessing contents within
}
}
}catch(){
}
}
英文:
I have an Azure Blob with many containers. Each container has multiple folders - and each folder has a bunch of files in it. I want to be able to grab all of the files and return them zipped. I'm currently only able to get one file at a time...
public void downloadAllFromBlob(String containerName){
CloudBlobClient blobClient = this.storageAccount.createCloudBlobClient();
try{
CloudBlobContainer container = blobClient.getContainerReference(containerName);
if(container.exists()){
// I want to grab all the files in the container and zip them
for(ListBlobItem blobItem: container.listBlobs()){
// i'm only able to list/VIEW the blobs, and not go into one and get all the contents
}
}
}catch(){
}
}
答案1
得分: 2
抱歉,在Azure Blob Storage中,目前没有批量检索功能可用。您需要像您上面所示的那样逐个下载每个 Blob。您可以尝试并行检索 Blob 以加快速度。
英文:
Unfortunately there's no batch retrieve capability available in Azure Blob Storage. You need need to download each blob individually as you showed above. You can try to retrieve blobs in parallel to speed things up.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论