gpt4 book ai didi

c# - Windows 通用应用程序 - 从 Azure 容器下载所有 Blob

转载 作者:行者123 更新时间:2023-12-03 03:12:29 24 4
gpt4 key购买 nike

我有一个通用 Windows 应用程序。

我试图在应用程序启动时从 azure 容器下载所有 blob。这是我的代码:

 public MainPage()
{
this.InitializeComponent();
downloadblobs();
}

public async void downloadblobs()
{
CloudStorageAccount storageaccount = new CloudStorageAccount(new StorageCredentials("accountname", "accountkey"), true);
CloudBlobClient blobClient = storageaccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("ContainerName");

//---------------------
int fileName = 1;
var client = storageaccount.CreateCloudBlobClient();
BlobContinuationToken continuationToken = null;
string prefix = null;
bool useFlatBlobListing = true;
BlobListingDetails blobListingDetails = BlobListingDetails.All;
int maxBlobsPerRequest = 2500;
List<IListBlobItem> blobs = new List<IListBlobItem>();
do
{
var listingResult = await container.ListBlobsSegmentedAsync(prefix, useFlatBlobListing, blobListingDetails, maxBlobsPerRequest, continuationToken, null, null);
continuationToken = listingResult.ContinuationToken;
blobs.AddRange(listingResult.Results);
using (var fileStream = System.IO.File.OpenWrite(@"\NewImages\" + fileName + ".jpg"))
{
var blobReference = blobClient.GetBlobReferenceFromServerAsync(blobs.Uri);
File downloadedFile = new File(blobReference + ".jpg");
fileName++;
}
}
while (continuationToken != null);
}

我在两行中收到错误:

            var blobReference = blobClient.GetBlobReferenceFromServerAsync(blobs.Uri);
File downloadedFile = new File(blobReference + ".jpg");

我的错误是:

ListBlobItem does not contain a definition of Uri.

Cannot declare variable of static type File.

Cannot create an instance of the static class file.

最佳答案

您需要使用 container.listBlobsSegmentedAsync() 枚举容器中的 Blob。容器引用不仅仅包含自动下载的 blob 列表。

有关引用,请参阅here .

关于c# - Windows 通用应用程序 - 从 Azure 容器下载所有 Blob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35232272/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com