Azure GetBlobReference属性为空后

时间:2017-04-27 13:51:52

标签: azure properties attributes

我尝试在BlobHelper下载之前或之前获取属性。 GetBlobReference ()用于登录,最后我尝试使用blob.FetchAttributes();但是doestn工作我的属性是null。我的容器和我的blob没有权限

         public static CloudBlob GetBlobReference(string containerName,string fileName)
         {
        var blobClient = GetBlobClient();
        if (blobClient != null)
           {
            var contRef=blobClient.GetContainerReference(containerName);
            return contRef.GetBlobReference(fileName);
            }
        return null;
          }

         var blob = BlobHelper.GetBlobReference(SelectedContainer, 
         fileName);

        if (blob.Properties != null)
        {
          //I try to get Lenght of blob but it is -1
        }

enter image description here

1 个答案:

答案 0 :(得分:1)

这是预期的行为。 GetBlobReference只是在客户端上创建CloudBlob的实例,并且不会发出网络请求。来自文档link

  

调用此方法以返回对此中任何类型的blob的引用   容器。 请注意,此方法不会针对Blob发出请求   存储。您可以返回对blob的引用,无论它是否存在   还存在。

如果您想要填充属性,则必须致电FetchAttributes或使用GetBlobReferenceFromServer