问题
I need to download 1000 small images from my Azure Blob Storage. I don't want to make a separate request for each file. How to do this in c#?
Right now I am using Azure.Storage.Blobs
and Azure.Storage.Blobs.Batch
but neither of them have this API. The latter one has only DeleteBlobs
call at the moment of posting this question.
回答1:
I need to download 1000 small images from my Azure Blob Storage. I don't want to make a separate request for each file. How to do this in c#?
Unfortunately there's no batch download capability available in Azure Blob Storage. You will need to download each blob individually. What you could do is download blobs in parallel to speed things up.
回答2:
You could speed up the download by downloading in parallel.
var semaphore = new SemaphoreSlim(100);
List<Task> downloadTasks = new List<Task>();
foreach (var fileName in fileNames)
{
await semaphore.WaitAsync();
downloadTasks.Add(Task.Run(async () =>
{
// here download the file
semaphore.Release();
}));
}
await Task.WhenAll(downloadTasks);
来源:https://stackoverflow.com/questions/60950802/how-to-download-multiple-files-in-a-single-request-from-azure-blob-storage-using