[英]How to download a blob from Azure Storage with conditionals?
我正在嘗試從 Azure Blob 存儲下載一些圖像,我需要將一些條件放入其中。 到目前為止,我一直在處理文件名,上傳帶有名稱數據的文件,以便稍后將其用作條件,但我想知道其他一些方法。
到目前為止,我試圖從日期間隔獲取圖像:
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);
}
}
替代解決方案:我會將文件名存儲到 SQL 數據庫和其他對我有用的數據中。 當我需要下載一些內容時,我可以做一個簡單的查詢返回文件名,然后通過 Azure 存儲包下載。
無論如何,如果有人知道更好的選擇,我很高興知道。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.