【发布时间】:2020-10-15 16:40:20
【问题描述】:
我在 Azure 中有一个名为 productimages 的子文件夹。在 productimages 文件夹中我现在有很多图像,我想获取图像 URL 以及文件大小。我能够获取 URL,但无法获取文件大小。另一件事是,当我从 blob 获取 URL 时,它并没有按顺序出现,例如,它不是以 1.jpg、2.jpg 的形式出现,而是像 9999.jpg .... 1.jpg。
我的代码:
public List<ProductDataVM> RetrieveFileInfoFromBlob()
{
List<ProductDataVM> plists = new List<ProductDataVM>();
var files = container.ListBlobs(prefix: "productimages/", useFlatBlobListing: true);
var cnt = files.Count();
foreach (var file in files)
{
ProductDataVM ob = new ProductDataVM();
ob.ImageUrl = file.Uri.ToString();
ob.FileSize = file.Properties.Length; // in this line it gives IListBlobItem' does not contain a definition for 'Properties'
plists.Add(ob);
}
return plists;
}
我们将不胜感激。
【问题讨论】:
-
我认为你只是缺少 file.FetchAttributes();在调用 file.Properties.Length;
-
@JohnD 感谢您的友好回复,但没有找到类似 file.FetchAttributes() 的内容。
-
你可能想在这里检查类似的问题:stackoverflow.com/questions/25281492/…
标签: c# azure-blob-storage