/** * Reads or downloads a blob from the system, including its metadata and * properties. * * @param string $container name of the container * @param string $blob name of the blob * @param Models\GetBlobOptions $options optional parameters * * @return Models\GetBlobResult * * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179440.aspx */ public function getBlob($container, $blob, $options = null) { Validate::isString($container, 'container'); Validate::isString($blob, 'blob'); $method = Resources::HTTP_GET; $headers = array(); $postParams = array(); $queryParams = array(); $path = $this->_createPath($container, $blob); $statusCode = array(Resources::STATUS_OK, Resources::STATUS_PARTIAL_CONTENT); if (is_null($options)) { $options = new GetBlobOptions(); } $getMD5 = $options->getComputeRangeMD5(); $headers = $this->addOptionalAccessConditionHeader($headers, $options->getAccessCondition()); $headers = $this->_addOptionalRangeHeader($headers, $options->getRangeStart(), $options->getRangeEnd()); $this->addOptionalHeader($headers, Resources::X_MS_LEASE_ID, $options->getLeaseId()); $this->addOptionalHeader($headers, Resources::X_MS_RANGE_GET_CONTENT_MD5, $getMD5 ? 'true' : null); $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout()); $this->addOptionalQueryParam($queryParams, Resources::QP_SNAPSHOT, $options->getSnapshot()); $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode); $metadata = $this->getMetadataArray(HttpFormatter::formatHeaders($response->getHeaders())); return GetBlobResult::create(HttpFormatter::formatHeaders($response->getHeaders()), $response->getBody(), $metadata); }
/** * @covers MicrosoftAzure\Storage\Blob\Models\GetBlobOptions::getSnapshot */ public function testGetSnapshot() { // Setup $blob = new GetBlobOptions(); $expected = TestResources::QUEUE_URI; $blob->setSnapshot($expected); // Test $actual = $blob->getSnapshot(); // Assert $this->assertEquals($expected, $actual); }