How to get Azure Blob file size

后端 未结 2 1086
广开言路
广开言路 2021-02-02 09:04

I used Azure blob to store images. Users upload those images. I want to see how much space each user occupy with their images. How can I do that in ASP.NET code behind? Can I ge

2条回答
  •  甜味超标
    2021-02-02 09:58

    You need to fetch a blob's properties first. Eg,

    var blob = _container.GetBlockBlobReference(blobName);
    if (blob.Exists())
    {
        blob.FetchAttributes();
        return blob.Properties.Length;
    }
    
    throw new Exception("Blob doesn't exist");
    

提交回复
热议问题