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';
}