How to get Azure Blob file size

后端 未结 2 1045
广开言路
广开言路 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:49

    Answering for scala/java here, in case someone is stuck. In order to get the size of the blob you can make use of the following code:

    val blob: CloudBlockBlob = container.getBlockBlobReference(blobPath)
    blob.downloadAttributes()
    blob.getProperties.getLength
    

    Make sure you definitely call downloadAttributes else the properties will be empty.

    You can refer to this documentation for more details https://docs.microsoft.com/en-us/java/api/com.microsoft.azure.storage.blob.cloudblockblob?view=azure-java-legacy

提交回复
热议问题