コード例 #1
0
 /**
  * Creates GetBlobResult from getBlob call.
  * 
  * @param array  $headers  The HTTP response headers.
  * @param string $body     The response body.
  * @param array  $metadata The blob metadata.
  * 
  * @return GetBlobResult
  */
 public static function create($headers, $body, $metadata)
 {
     $result = new GetBlobResult();
     $result->setContentStream(Utilities::stringToStream($body));
     $result->setProperties(BlobProperties::create($headers));
     $result->setMetadata(is_null($metadata) ? array() : $metadata);
     return $result;
 }
コード例 #2
0
 /**
  * @covers MicrosoftAzure\Storage\Blob\Models\GetBlobResult::setContentStream
  * @covers MicrosoftAzure\Storage\Blob\Models\GetBlobResult::getContentStream
  */
 public function testSetContentStream()
 {
     // Setup
     $expected = Utilities::stringToStream('0x8CAFB82EFF70C46');
     $result = new GetBlobResult();
     // Test
     $result->setContentStream($expected);
     // Assert
     $this->assertEquals($expected, $result->getContentStream());
 }
コード例 #3
0
 /**
  * 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);
 }