在Xamarin Forms中,我试图从Azure下载blob图像并存储在本地。下面的代码可以正常工作,但是目前我所能做的就是遍历每个图像的名称,我正在努力解决下载部分。
下面的第二个代码片段显示了我认为应该的内容,但是我不确定应该将什么内容传递给GetBlockBlobReference,或者在哪里找到它,所以基本上我想从列出图像开始完成下载,有人可以建议我需要做什么吗?
public async Task ProcessAsync()
{
storageAccount = CloudStorageAccount.Parse(Resx.Apis.BlobStorageDev);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(Resx.AppResources.blobContainer);
BlobContinuationToken blobContinuationToken = null;
do
{
var results = await container.ListBlobsSegmentedAsync(null, blobContinuationToken);
blobContinuationToken = results.ContinuationToken;
await DownloadAsync(results);
foreach (IListBlobItem item in results.Results)
{
// here we'll check against what's in local, download if needed
Debug.WriteLine(item.Uri);
}
} while (blobContinuationToken != null);
}
下载位:
CloudBlockBlob cloudBlockBlob = cloudBlobContainer.GetBlockBlobReference(???);
foreach (var listBlockItem in await cloudBlockBlob.DownloadBlockListAsync(BlockListingFilter.All, null, null, null))
{
}
答案 0 :(得分:0)
您需要将路径传递到blob容器内的blob。因此,例如,如果blob的完整路径是“ https://youraccount.blob.core.windows.net/container_name/folder1/folder2/file-name.bin”,那么您需要传递“ folder1 / folder2 / file-name”。 bin”。