/**
  * Creates SetBlobMetadataResult from response headers.
  * 
  * @param array $headers response headers
  * 
  * @return SetBlobMetadataResult
  */
 public static function create($headers)
 {
     $result = new SetBlobMetadataResult();
     $date = $headers[Resources::LAST_MODIFIED];
     $result->setLastModified(Utilities::rfc1123ToDateTime($date));
     $result->setETag($headers[Resources::ETAG]);
     return $result;
 }
Exemple #2
0
 /**
  * Sets metadata headers on the blob.
  * 
  * @param string                        $container name of the container
  * @param string                        $blob      name of the blob
  * @param array                         $metadata  key/value pair representation
  * @param Models\SetBlobMetadataOptions $options   optional parameters
  * 
  * @return Models\SetBlobMetadataResult
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179414.aspx
  */
 public function setBlobMetadata($container, $blob, $metadata, $options = null)
 {
     Validate::isString($container, 'container');
     Validate::isString($blob, 'blob');
     Validate::notNullOrEmpty($blob, 'blob');
     $this->validateMetadata($metadata);
     $method = Resources::HTTP_PUT;
     $headers = array();
     $postParams = array();
     $queryParams = array();
     $path = $this->_createPath($container, $blob);
     $statusCode = Resources::STATUS_OK;
     if (is_null($options)) {
         $options = new SetBlobMetadataOptions();
     }
     $headers = $this->addOptionalAccessConditionHeader($headers, $options->getAccessCondition());
     $headers = $this->addMetadataHeaders($headers, $metadata);
     $this->addOptionalHeader($headers, Resources::X_MS_LEASE_ID, $options->getLeaseId());
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'metadata');
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode);
     return SetBlobMetadataResult::create($response->getHeader());
 }
 /**
  * @covers WindowsAzure\Blob\Models\SetBlobMetadataResult::setLastModified
  */
 public function testSetLastModified()
 {
     // Setup
     $getBlobMetadataResult = new SetBlobMetadataResult();
     $expected = Utilities::rfc1123ToDateTime('Fri, 09 Oct 2009 21:04:30 GMT');
     // Test
     $getBlobMetadataResult->setLastModified($expected);
     // Assert
     $actual = $getBlobMetadataResult->getLastModified();
     $this->assertEquals($expected, $actual);
 }