/** * Creates GetBlobMetadataResult from response headers. * * @param array $headers The HTTP response headers. * @param array $metadata The blob metadata array. * * @return GetBlobMetadataResult */ public static function create($headers, $metadata) { $result = new GetBlobMetadataResult(); $date = $headers[Resources::LAST_MODIFIED]; $result->setLastModified(Utilities::rfc1123ToDateTime($date)); $result->setETag($headers[Resources::ETAG]); $result->setMetadata(is_null($metadata) ? array() : $metadata); return $result; }
/** * @covers MicrosoftAzure\Storage\Blob\Models\GetBlobMetadataResult::getMetadata */ public function testGetMetadata() { // Setup $container = new GetBlobMetadataResult(); $expected = array('key1' => 'value1', 'key2' => 'value2'); $container->setMetadata($expected); // Test $actual = $container->getMetadata(); // Assert $this->assertEquals($expected, $actual); }
/** * Returns all properties and metadata on the blob. * * @param string $container name of the container * @param string $blob name of the blob * @param Models\GetBlobMetadataOptions $options optional parameters * * @return Models\GetBlobMetadataResult * * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179350.aspx */ public function getBlobMetadata($container, $blob, $options = null) { Validate::isString($container, 'container'); Validate::isString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); $method = Resources::HTTP_HEAD; $headers = array(); $postParams = array(); $queryParams = array(); $path = $this->_createPath($container, $blob); $statusCode = Resources::STATUS_OK; if (is_null($options)) { $options = new GetBlobMetadataOptions(); } $headers = $this->addOptionalAccessConditionHeader($headers, $options->getAccessCondition()); $this->addOptionalHeader($headers, Resources::X_MS_LEASE_ID, $options->getLeaseId()); $this->addOptionalQueryParam($queryParams, Resources::QP_SNAPSHOT, $options->getSnapshot()); $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout()); $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'metadata'); $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode); $responseHeaders = HttpFormatter::formatHeaders($response->getHeaders()); $metadata = $this->getMetadataArray($responseHeaders); return GetBlobMetadataResult::create($responseHeaders, $metadata); }