/** * Get an item from the storage service. * * @param string $path * @param array $options * @return mixed */ public function fetchItem($path, $options = null) { // Options $returnType = self::RETURN_STRING; $returnPath = tempnam('', 'azr'); $openMode = 'r'; // Parse options if (is_array($options)) { if (isset($options[self::RETURN_TYPE])) { $returnType = $options[self::RETURN_TYPE]; } if (isset($options[self::RETURN_PATHNAME])) { $returnPath = $options[self::RETURN_PATHNAME]; } if (isset($options[self::RETURN_OPENMODE])) { $openMode = $options[self::RETURN_OPENMODE]; } } // Fetch the blob try { $this->_storageClient->getBlob( $this->_container, $path, $returnPath ); } catch (WindowsAzureException\ExceptionInterface $e) { if (strpos($e->getMessage(), "does not exist") !== false) { return false; } throw new Exception\RuntimeException('Error on fetch: '.$e->getMessage(), $e->getCode(), $e); } // Return value if ($returnType == self::RETURN_PATH) { return $returnPath; } if ($returnType == self::RETURN_STRING) { return file_get_contents($returnPath); } if ($returnType == self::RETURN_STREAM) { return fopen($returnPath, $openMode); } }