【问题标题】:How to Get CloudBlobDirectory Storage Utilised如何使用 CloudBlobDirectory 存储
【发布时间】:2019-04-06 06:48:17
【问题描述】:

我试图在不通过 C# 代码迭代列表的情况下一次性获取 CloudBlobDirectory 上的图像大小,因为迭代需要时间来加载页面。

我在网上搜索过,但所有代码都通过列表迭代显示。

if (cloudBlobContainer.Exists() == true)
{
    CloudBlobDirectory folder = cloudBlobContainer.GetDirectoryReference(Subcontainer);
    foreach (var blobItem in folder.ListBlobs())
    {
        try
        {
            var blob = blobItem as CloudBlockBlob;
            if (blob != null)
                filesize += blob.Properties.Length;
        }
        catch { continue; }
    }
}

时间只关心它应该在 2-3 秒内返回结果作为大量图像以显示 Azure 存储的占用大小。

【问题讨论】:

标签: c# azure-storage azure-blob-storage


【解决方案1】:

如果您只关心时间,请将“长度”保存到某个位置(数据库或文件)。

如果上传到 blob 由您控制,请在上传时保存文件长度。如果没有,请在特定时间段(例如每 5 分钟)运行一个程序扫描文件并保存文件长度。

【讨论】:

  • 不客气。如果需要,将此答案标记为答案。
【解决方案2】:

不,您必须列出 blob 并计算总大小。

【讨论】:

    猜你喜欢
    • 2012-02-29
    • 2020-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多