简体   繁体   English

如何使用条件从 Azure 存储下载 blob?

[英]How to download a blob from Azure Storage with conditionals?

I'm trying to download some images from Azure Blob Storage and I need to put some conditionals into it.我正在尝试从 Azure Blob 存储下载一些图像,我需要将一些条件放入其中。 I'm working around with file name until now, uploading them with datas on the name so I can use it as conditionals later, but I was wondering some other way to do it.到目前为止,我一直在处理文件名,上传带有名称数据的文件,以便稍后将其用作条件,但我想知道其他一些方法。

What I was trying to do so far to get images from a date interval:到目前为止,我试图从日期间隔获取图像:

public async void DownloadBlobAsync(string blobName, string savePath, System.DateTime fromThisDate, System.DateTime toThisDate)
        {          
            var blobs = ListBlobsAsync(); //List all blobs in the current container
            var wantedBlobs = new List<string>(); //After conditionals work, I'll fill up this list with the blob names I want to download

            foreach (var blob in blobs.Result)
            {
                //All stuff about convertion from string do DateTime                
            }

            foreach (var blob in wantedBlobs)
            {
                var blobClient = blobContainerClient.GetBlobClient(blob);
                var downloadedBlob = await blobClient.DownloadAsync();

                System.Drawing.Image.FromStream(downloadedBlob.Value.Content).Save(savePath);
            }
        }

Alternative Solution: I'll store the file name into a SQL Database and other usefull datas for me.替代解决方案:我会将文件名存储到 SQL 数据库和其他对我有用的数据中。 When I need download some content, I can do a simple query to return the file name and then download through the Azure Storage Package.当我需要下载一些内容时,我可以做一个简单的查询返回文件名,然后通过 Azure 存储包下载。

Anyway, in case of someone know a better alternative, I'd be glad to know.无论如何,如果有人知道更好的选择,我很高兴知道。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM