如何获取Azure Blob文件大小 [英] How to get Azure Blob file size

查看:157
本文介绍了如何获取Azure Blob文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Azure blob存储图像.用户上传这些图像.我想看看每个用户用其图像占用多少空间.我该如何在背后的ASP.NET代码中做到这一点?是否可以仅通过知道URI来获得图像文件的大小?还是我需要使用一些与Blob相关的功能?

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 get an image file size just by knowing its URI? Or do I need use some blob related function?

推荐答案

您需要先获取blob的属性.例如,

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");

这篇关于如何获取Azure Blob文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆