[英]Azure Storage - Download a blob with conditions
在使用Azure 存儲 SDK時嘗試下載 blob 時,我一直無法在 blob 上分配讀取條件。
基本上,我想做的是這樣的:
blobRef.GetProperties().Etag
( WORKS ) 獲取 blob 的 EtagRequestFailedException e
其中e.ErrorCode == ConditionNotMet
( FAILS )這是代碼:
var condition = new Azure.Storage.Blobs.Models.BlobRequestConditions
{
IfNoneMatch = new Azure.ETag(previousEtagString),
};
//blobRef is a valid instance of Azure.Storage.Blobs.BlobClient
//target is the filePath
blobRef.DownloadTo(target, conditions: condition); // this should throw RequestFailedException
筆記:
當我嘗試將從步驟 3 獲取的 Etag(轉換為字符串)與我在步驟 4 中發送的 Etag 進行比較時,它返回它們是相同的blobRef.GetProperties().Etag == new Azure.Etag(blobRef.GetProperties().Etag.ToString())
-> true
我還在 GitHub 回購中打開了這個問題
使用 v11 通過測試用例:
var blobRef = _blobContainer.GetBlockBlobReference(identifier); blobRef.DownloadTo(target, AccessCondition.GenerateIfNoneMatchCondition(stringEtag)); //throws StorageException
剛剛注意到第二次下載的blob,不包含任何數據。 它是空的。 第一個有數據。 讀取條件是否部分有效,但未引發異常?
謝謝
使用 Etag 再次嘗試下載 blob 並期待 RequestFailedException e 其中 e.ErrorCode == ConditionNotMet
這不是預期的行為,因為 Etag 僅在更新 blob 時更改。
如果 blob 未更新,則 Etag 值保持不變。 因此,如果您不更新 blob,則可以多次執行條件下載,而不會出現先決條件失敗錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.