1
我有一個通用Windows應用程序。Windows通用應用程序 - 從Azure Container下載所有Blob
我想在應用程序啓動時從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);
}
IM在兩行收到錯誤:
var blobReference = blobClient.GetBlobReferenceFromServerAsync(blobs.Uri);
File downloadedFile = new File(blobReference + ".jpg");
我的錯誤是:
ListBlobItem不包含的Uri的定義。
無法聲明靜態類型File的變量。
和
無法創建靜態類文件的一個實例。
我試圖做到這一點使用這個鏈接:https://ahmetalpbalkan.com/blog/azure-listblobssegmentedasync-listcontainerssegmentedasync-how-to/和這個鏈接http://stackoverflow.com/questions/16052813/越來越列表的Blob在WinTOR應用程序,但不能得到它的工作。我完全失去了! – DMur
您應該編輯您的問題以顯示您嘗試的內容,關於'listBlobsSegmentedAsync()'。這樣,有人可能會提供幫助。但底線:由於您從不檢索blob列表,因此您當前的實施將無法工作。 –
你有鏈接到發送blob贏得通用設備的教程嗎?所有的tut的在線只是告訴你如何將它們上傳到天藍色(我認爲這是blobs旅行的明顯方向,但我正在爲其他東西搞亂並希望下載它們) – DMur