简体   繁体   English

Azure 存储 blob 下载旧文件版本

[英]Azure storage blob downloads old file version

I am facing the issue while downloading of azure blob file with old file being downloaded.Here are the steps.我在下载 azure blob 文件并下载旧文件时遇到问题。这是步骤。

While uploading.. following code is used.上传时..使用以下代码。

                BlobClient blobClient = containerClient.GetBlobClient(fileNamePrefix);
                if (blobClient.Exists())
                {
                    await blobClient.DeleteIfExistsAsync(DeleteSnapshotsOption.IncludeSnapshots);
                    await blobClient.UploadAsync(stream, true);
                }

While above process works well, and in blob storage, i see updated file, if the same blob already existed.虽然上述过程运行良好,并且在 blob 存储中,如果相同的 blob 已经存在,我会看到更新的文件。

After this is done, If i perform download operation.完成后,如果我执行下载操作。

BlobClient blobClient = containerClient.GetBlobClient(blobName);
await blobClient.DownloadToAsync(mstream);

I still see old file.我仍然看到旧文件。 So even though, new file exists in storage, the operation gives me old file.因此,即使存储中存在新文件,该操作也会给我旧文件。

It's baffling why it happening, but any idea's would be useful.令人费解的是为什么会发生这种情况,但任何想法都是有用的。

Thank you.谢谢你。

Putting it here so anyone else faces problem.把它放在这里,以便其他人面临问题。 Will help them.会帮助他们。

You have to use BlobClient for Delete of snapshot.您必须使用 BlobClient 删除快照。 await blobClient.DeleteIfExistsAsync(DeleteSnapshotsOption.IncludeSnapshots, null, default);等待 blobClient.DeleteIfExistsAsync(DeleteSnapshotsOption.IncludeSnapshots,null,默认);

Please mark this as answer for others:)请将此标记为其他人的答案:)

I had the same behavior you have.我和你有同样的行为。 After logging out and log back in Azure, I did see the updated file as expected.注销并重新登录 Azure 后,我确实看到了预期的更新文件。

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

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