检查Azure中是否存在Blob [英] Check if blob exists in Azure
问题描述
我想知道是否有一种方法可以检查容器中是否存在斑点?
$blob = $blobRestProxy->getBlob("mycontainer", "myblobname");
if($blob){
return 'exists';
} else {
return 'not exists';
}
我已经尝试过,但是只要不存在blob,我都会收到此消息:
BlobNotFound
指定的Blob不存在.
如果存在,则代码自然返回存在".我对列出容器中的所有blob并进行迭代直到找到匹配原因不感兴趣,因为我有很多blob.
当blob不存在时,函数getBlob
将引发ServiceException
异常并退出PHP进度,以下代码将不起作用./p>
请尝试在代码中添加try catch语句,例如.
try {
$blob = $tableRestProxy->getBlob("mycontainer", "myblobname");
return 'exists';
} catch (ServiceException $e) {
return 'not exists';
}
I'm wondering if there is a way to check if a blob exists in a container?
$blob = $blobRestProxy->getBlob("mycontainer", "myblobname");
if($blob){
return 'exists';
} else {
return 'not exists';
}
I've tried this but im getting this message whenever the blob does not exists:
BlobNotFound
The specified blob does not exist.
If exists, the code returns 'exists' naturally. I'm not interested in listing all blobs in the container and iterating until I find a match cause I have a lot of blobs.
When the blob does not exist, the function getBlob
will raise a ServiceException
exception and exit the PHP progress, the following code will not work.
Please try to add the try catch statement in your code, E.G.
try {
$blob = $tableRestProxy->getBlob("mycontainer", "myblobname");
return 'exists';
} catch (ServiceException $e) {
return 'not exists';
}
这篇关于检查Azure中是否存在Blob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!