[英]URL of Blobs in Azure with directory structure
使用中的程序集:程序集 Microsoft.WindowsAzure.Storage,版本 = 9.3.1.0
我想做什么:在我的 Azure 存儲中,我將圖像存儲為 blob,格式如下
我想獲取所有圖像 blob 的 URL 及其最后修改的時間戳。
請注意, Image1
和Image4
可能具有相同的名稱。
我試過的:
我從容器的根目錄嘗試ListBlobsSegmentedAsync(BlobContinuationToken currentToken)
並使用GetDirectoryReference(string relativeAddress)
但無法獲得所需的結果。
雖然有點偏離軌道,但我可以通過GetBlockBlobReference(string blobName);
獲取 blob 詳細信息。
我應該怎么辦?
提前致謝。
ListBlobsSegmentedAsync
方法有 2 個包含useFlatBlobListing
參數的重載。 這些重載接受 7 或 8 arguments,我在您的代碼中數為 6。
使用以下代碼列出容器中的所有 blob。
public static async Task test()
{
StorageCredentials storageCredentials = new StorageCredentials("xxx", "xxxxx");
CloudStorageAccount storageAccount = new CloudStorageAccount(storageCredentials, true);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("container");
BlobContinuationToken blobContinuationToken = null;
var resultSegment = await container.ListBlobsSegmentedAsync(
prefix: null,
useFlatBlobListing: true,
blobListingDetails: BlobListingDetails.None,
maxResults: null,
currentToken: blobContinuationToken,
options: null,
operationContext: null
);
// Get the value of the continuation token returned by the listing call.
blobContinuationToken = resultSegment.ContinuationToken;
foreach (IListBlobItem item in resultSegment.Results)
{
Console.WriteLine(item.Uri);
}
}
結果如下:
請嘗試使用以下參數覆蓋ListBlobsSegmentedAsync
:
prefix: ""
useFlatBlobListing: true
blobListingDetails: BlobListingDetails.All
maxResults: 5000
currentToken: null or the continuation token returned
這將返回所有 blob 的列表(包括內部虛擬文件夾)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.