检查Azure中是否存在Blob [英] Check if blob exists in Azure

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

问题描述

我想知道是否有一种方法可以检查容器中是否存在斑点?

    $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:

BlobNotFoundThe 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屋!

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