如何从Azure Blob抓取所有文件并压缩它们?

问题描述

我有一个包含许多容器的Azure Blob。每个容器都有多个文件夹-每个文件夹中都有一堆文件。我希望能够获取所有文件并将其压缩后返回。我目前一次只能获取一个文件...

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(){
     }
}

解决方法

不幸的是,Azure Blob存储中没有可用的批量检索功能。如上所示,您需要单独下载每个Blob。您可以尝试并行检索blob以加快速度。