Gaufrette\Adapter\AzureBlobStorage::exists PHP Method

exists() public method

public exists ( $key )
    public function exists($key)
    {
        $this->init();
        $listBlobsOptions = new ListBlobsOptions();
        $listBlobsOptions->setPrefix($key);
        try {
            $blobsList = $this->blobProxy->listBlobs($this->containerName, $listBlobsOptions);
            foreach ($blobsList->getBlobs() as $blob) {
                if ($key === $blob->getName()) {
                    return true;
                }
            }
        } catch (ServiceException $e) {
            $this->failIfContainerNotFound($e, 'check if key exists');
            $errorCode = $this->getErrorCodeFromServiceException($e);
            throw new \RuntimeException(sprintf('Failed to check if key "%s" exists in container "%s": %s (%s).', $key, $this->containerName, $e->getErrorText(), $errorCode), $e->getCode());
        }
        return false;
    }