只读Blob元数据

时间:2019-02-13 14:10:42

标签: c# azure-storage-blobs

我从Azure blob存储中读取了blob

getScanResults

是否可以仅从Blob而不是Blob本身读取元数据(Url,created等)?这样一来,安全的流量就能获得更好的性能。

问候 斯蒂芬

1 个答案:

答案 0 :(得分:0)

是的,有可能。请参见下面的代码:

            BlobContinuationToken continuationToken = null;
            var resultSegment=cloudBlobContainer.ListBlobsSegmentedAsync("", true, BlobListingDetails.All, 100, continuationToken, null, null).Result;
            foreach (IListBlobItem item in resultSegment.Results)
            {
                #need a type conversion here
                var temp = item as CloudBlockBlob;

                #this line of code is needed for fetch attribute and metadata.
                temp.FetchAttributes();
                Console.WriteLine("URL: {0}", temp.StorageUri.PrimaryUri.ToString());
                Console.WriteLine("Creation time: {0}", temp.Properties.Created.ToString());
            }

测试结果:

enter image description here

顺便说一句,您提到的(Url, created, … )是Blob属性。如果要获取Blob的元数据,则应遵循此link并确保之前已设置元数据。

相关问题