Ejemplo n.º 1
0
 /**
  * Creates CreateBlobPagesResult object from $parsed response in array 
  * representation
  * 
  * @param array $headers HTTP response headers
  * 
  * @return CreateBlobPagesResult
  */
 public static function create($headers)
 {
     $result = new CreateBlobPagesResult();
     $clean = array_change_key_case($headers);
     $date = $clean[Resources::LAST_MODIFIED];
     $date = Utilities::rfc1123ToDateTime($date);
     $result->setETag($clean[Resources::ETAG]);
     $result->setLastModified($date);
     $result->setContentMD5(Utilities::tryGetValue($clean, Resources::CONTENT_MD5));
     $result->setSequenceNumber(intval(Utilities::tryGetValue($clean, Resources::X_MS_BLOB_SEQUENCE_NUMBER)));
     return $result;
 }
 /**
  * @covers WindowsAzure\Blob\Models\CreateBlobPagesResult::setSequenceNumber
  * @covers WindowsAzure\Blob\Models\CreateBlobPagesResult::getSequenceNumber
  */
 public function testSetSequenceNumber()
 {
     // Setup
     $expected = 123;
     $options = new CreateBlobPagesResult();
     $options->setSequenceNumber($expected);
     // Test
     $options->setSequenceNumber($expected);
     // Assert
     $this->assertEquals($expected, $options->getSequenceNumber());
 }
Ejemplo n.º 3
0
 /**
  * Does actual work for create and clear blob pages.
  * 
  * @param string                 $action    Either clear or create.
  * @param string                 $container The container name.
  * @param string                 $blob      The blob name.
  * @param PageRange              $range     The page ranges.
  * @param string|resource        $content   The content stream.
  * @param CreateBlobPagesOptions $options   The optional parameters.
  * 
  * @return CreateBlobPagesResult
  */
 private function _updatePageBlobPagesImpl($action, $container, $blob, $range, $content, $options = null)
 {
     Validate::isString($blob, 'blob');
     Validate::notNullOrEmpty($blob, 'blob');
     Validate::isString($container, 'container');
     Validate::isTrue($range instanceof PageRange, sprintf(Resources::INVALID_PARAM_MSG, 'range', get_class(new PageRange())));
     Validate::isTrue(is_string($content) || is_resource($content), sprintf(Resources::INVALID_PARAM_MSG, 'content', 'string|resource'));
     $method = Resources::HTTP_PUT;
     $headers = array();
     $queryParams = array();
     $postParams = array();
     $path = $this->_createPath($container, $blob);
     $statusCode = Resources::STATUS_CREATED;
     // If read file failed for any reason it will throw an exception.
     $body = is_resource($content) ? stream_get_contents($content) : $content;
     if (is_null($options)) {
         $options = new CreateBlobPagesOptions();
     }
     $headers = $this->_addOptionalRangeHeader($headers, $range->getStart(), $range->getEnd());
     $headers = $this->addOptionalAccessConditionHeader($headers, $options->getAccessCondition());
     $this->addOptionalHeader($headers, Resources::X_MS_LEASE_ID, $options->getLeaseId());
     $this->addOptionalHeader($headers, Resources::CONTENT_MD5, $options->getContentMD5());
     $this->addOptionalHeader($headers, Resources::X_MS_PAGE_WRITE, $action);
     $this->addOptionalHeader($headers, Resources::CONTENT_TYPE, Resources::URL_ENCODED_CONTENT_TYPE);
     $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'page');
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode, $body);
     return CreateBlobPagesResult::create($response->getHeader());
 }