检查是否在Azure存储中存在一个blob [英] Checking if a blob exists in Azure Storage

查看:108
本文介绍了检查是否在Azure存储中存在一个blob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很简单的问题(我希望!) - 我只是想看看一个blob(带我定义的名称)在一个特定的容器存在。我会下载它,如果它确实存在,如果没有的话,我会做别的事情。

I've got a very simple question (I hope!) - I just want to find out if a blob (with a name I've defined) exists in a particular container. I'll be downloading it if it does exist, and if it doesn't then I'll do something else.

我已经做了一些搜索的intertubes,显然过去有一种叫做DoesExist或类似功能...但有这么多在Azure的API,这似乎不再是那里(或者如果它是,有一个非常巧妙伪装的名称)。

I've done some searching on the intertubes and apparently there used to be a function called DoesExist or something similar... but as with so many of the Azure APIs, this no longer seems to be there (or if it is, has a very cleverly disguised name).

推荐答案

注意:这个答案是过时了。请参见下面的简单方法理查德的答案,检查它是否存在

没有,你不是简单的东西......我们确实在新StorageClient库中隐藏这种方法的一个好工作。 :)

No, you're not missing something simple... we did a good job of hiding this method in the new StorageClient library. :)

我刚写了一篇博客文章来回答你的问题:<一href=\"http://blog.smarx.com/posts/testing-existence-of-a-windows-azure-blob\">http://blog.smarx.com/posts/testing-existence-of-a-windows-azure-blob.

I just wrote a blog post to answer your question: http://blog.smarx.com/posts/testing-existence-of-a-windows-azure-blob.

简短的回答是:使用CloudBlob.FetchAttributes(),它不反对BLOB HEAD请求

The short answer is: use CloudBlob.FetchAttributes(), which does a HEAD request against the blob.

这篇关于检查是否在Azure存储中存在一个blob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆