0
我有一堆在azure存儲上的blob,它遵循以下模式中的名稱:<someName>_DateTimeOffset.UtcNow
。當我使用container.ListBlobs()
獲取blob時,blob Uri如下所示:<someName>__11%252f3%252f2014+10%253a00%253a00+PM+%252b00%253a00+%252b00%253a00
。如何刪除編碼名稱的天藍色blob?
如果你仔細觀察,%25
編碼時,一次和%2f
成爲:
變得%
。所以它看起來像Uri經歷了雙重編碼。
當我試圖獲得這個blob,它不起作用。以下是代碼片段:
BlobResultSegment resultSegment = await container.ListBlobsSegmentedAsync("myPrefix", true, BlobListingDetails.All, 10, null, null, null);
var list = resultSegment.Results.Select(x => x.Uri.ToString().Split('/').Last());
var blob = container.GetBlockBlobReference(blobName);
blob.FetchAttributes();
foreach (var element in list)
{
var blob = container.GetBlockBlobReference(element);
blob.FetchAttributes();
var t = blob.Metadata;
}
任何想法如何在嘗試訪問URL之前對URL進行編碼?
注:我使用最新的Azure存儲庫
這樣的回答可以幫助:http://stackoverflow.com/questions/1405048/how-do-i-decode-a-url-parameter-using-c你可能只需要解碼一次,但嘗試兩次,如果它不起作用。 (請參見http://msdn.microsoft.com/en-us/library/system.net.webutility.urlencode(v=vs.110).aspx for nonASP.net回答) – dodald 2014-11-06 20:15:17
已嘗試WebUtility.UrlDecode(WebUtility。 UrlDecode(blobName)),WebUtility.UrlDecode(blobName),HttpUtility.UrlDecode(blobName)等,他們都沒有工作。不太確定內部是如何表示blob名稱的。 – Amit 2014-11-06 20:36:47