コード例 #1
0
 /**
  * @covers WindowsAzure\Blob\Models\SetBlobPropertiesOptions::__construct
  */
 public function test__construct()
 {
     // Setup
     $expectedLength = 10;
     $blobProperties = new BlobProperties();
     $blobProperties->setContentLength($expectedLength);
     // Test
     $options = new SetBlobPropertiesOptions($blobProperties);
     // Assert
     $this->assertNotNull($options);
     $this->assertEquals($expectedLength, $options->getBlobContentLength());
 }
コード例 #2
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;
 }
コード例 #3
0
 /**
  * Builds the normalized output array from a Blob object.
  *
  * @param string         $path
  * @param BlobProperties $properties
  *
  * @return array
  */
 protected function normalizeBlobProperties($path, BlobProperties $properties)
 {
     return ['path' => $path, 'timestamp' => (int) $properties->getLastModified()->format('U'), 'dirname' => Util::dirname($path), 'mimetype' => $properties->getContentType(), 'size' => $properties->getContentLength(), 'type' => 'file'];
 }
コード例 #4
0
 /**
  * Creates ListBlobsResult object from parsed XML response.
  *
  * @param array $parsed XML response parsed into array.
  * 
  * @return WindowsAzure\Blob\Models\ListBlobsResult.
  */
 public static function create($parsed)
 {
     $result = new ListBlobsResult();
     $result->_prefix = Utilities::tryGetValue($parsed, Resources::QP_PREFIX);
     $result->_marker = Utilities::tryGetValue($parsed, Resources::QP_MARKER);
     $result->_nextMarker = Utilities::tryGetValue($parsed, Resources::QP_NEXT_MARKER);
     $result->_maxResults = intval(Utilities::tryGetValue($parsed, Resources::QP_MAX_RESULTS, 0));
     $result->_delimiter = Utilities::tryGetValue($parsed, Resources::QP_DELIMITER);
     $result->_blobs = array();
     $result->_blobPrefixes = array();
     $rawBlobs = array();
     $rawBlobPrefixes = array();
     if (is_array($parsed['Blobs']) && array_key_exists('Blob', $parsed['Blobs'])) {
         $rawBlobs = Utilities::getArray($parsed['Blobs']['Blob']);
     }
     foreach ($rawBlobs as $value) {
         $blob = new Blob();
         $blob->setName($value['Name']);
         $blob->setUrl($value['Url']);
         $blob->setSnapshot(Utilities::tryGetValue($value, 'Snapshot'));
         $blob->setProperties(BlobProperties::create(Utilities::tryGetValue($value, 'Properties')));
         $blob->setMetadata(Utilities::tryGetValue($value, Resources::QP_METADATA, array()));
         $result->_blobs[] = $blob;
     }
     if (is_array($parsed['Blobs']) && array_key_exists('BlobPrefix', $parsed['Blobs'])) {
         $rawBlobPrefixes = Utilities::getArray($parsed['Blobs']['BlobPrefix']);
     }
     foreach ($rawBlobPrefixes as $value) {
         $blobPrefix = new BlobPrefix();
         $blobPrefix->setName($value['Name']);
         $result->_blobPrefixes[] = $blobPrefix;
     }
     return $result;
 }
コード例 #5
0
 /**
  * Creates BlobProperties object from $parsed response in array representation
  * 
  * @param array $parsed parsed response in array format.
  * 
  * @return BlobProperties
  */
 public static function create($parsed)
 {
     $result = new BlobProperties();
     $clean = array_change_key_case($parsed);
     $date = Utilities::tryGetValue($clean, Resources::LAST_MODIFIED);
     $result->setBlobType(Utilities::tryGetValue($clean, 'blobtype'));
     $result->setContentLength(intval($clean[Resources::CONTENT_LENGTH]));
     $result->setETag(Utilities::tryGetValue($clean, Resources::ETAG));
     if (!is_null($date)) {
         $date = Utilities::rfc1123ToDateTime($date);
         $result->setLastModified($date);
     }
     $result->setLeaseStatus(Utilities::tryGetValue($clean, 'leasestatus'));
     $result->setLeaseStatus(Utilities::tryGetValue($clean, Resources::X_MS_LEASE_STATUS, $result->getLeaseStatus()));
     $result->setSequenceNumber(intval(Utilities::tryGetValue($clean, Resources::X_MS_BLOB_SEQUENCE_NUMBER)));
     $result->setContentRange(Utilities::tryGetValue($clean, Resources::CONTENT_RANGE));
     $result->setCacheControl(Utilities::tryGetValue($clean, Resources::CACHE_CONTROL));
     $result->setBlobType(Utilities::tryGetValue($clean, Resources::X_MS_BLOB_TYPE, $result->getBlobType()));
     $result->setContentEncoding(Utilities::tryGetValue($clean, Resources::CONTENT_ENCODING));
     $result->setContentLanguage(Utilities::tryGetValue($clean, Resources::CONTENT_LANGUAGE));
     $result->setContentMD5(Utilities::tryGetValue($clean, Resources::CONTENT_MD5));
     $result->setContentType(Utilities::tryGetValue($clean, Resources::CONTENT_TYPE));
     return $result;
 }
コード例 #6
0
ファイル: BlobRestProxy.php プロジェクト: yszar/linuxwp
 /**
  * Creates GetBlobPropertiesResult from headers array.
  * 
  * @param array $headers The HTTP response headers array.
  * 
  * @return GetBlobPropertiesResult
  */
 private function _getBlobPropertiesResultFromResponse($headers)
 {
     $result = new GetBlobPropertiesResult();
     $properties = new BlobProperties();
     $d = $headers[Resources::LAST_MODIFIED];
     $bType = $headers[Resources::X_MS_BLOB_TYPE];
     $cLength = intval($headers[Resources::CONTENT_LENGTH]);
     $lStatus = Utilities::tryGetValue($headers, Resources::X_MS_LEASE_STATUS);
     $cType = Utilities::tryGetValue($headers, Resources::CONTENT_TYPE);
     $cMD5 = Utilities::tryGetValue($headers, Resources::CONTENT_MD5);
     $cEncoding = Utilities::tryGetValue($headers, Resources::CONTENT_ENCODING);
     $cLanguage = Utilities::tryGetValue($headers, Resources::CONTENT_LANGUAGE);
     $cControl = Utilities::tryGetValue($headers, Resources::CACHE_CONTROL);
     $etag = $headers[Resources::ETAG];
     $metadata = $this->getMetadataArray($headers);
     if (array_key_exists(Resources::X_MS_BLOB_SEQUENCE_NUMBER, $headers)) {
         $sNumber = intval($headers[Resources::X_MS_BLOB_SEQUENCE_NUMBER]);
         $properties->setSequenceNumber($sNumber);
     }
     $properties->setBlobType($bType);
     $properties->setCacheControl($cControl);
     $properties->setContentEncoding($cEncoding);
     $properties->setContentLanguage($cLanguage);
     $properties->setContentLength($cLength);
     $properties->setContentMD5($cMD5);
     $properties->setContentType($cType);
     $properties->setETag($etag);
     $properties->setLastModified(Utilities::rfc1123ToDateTime($d));
     $properties->setLeaseStatus($lStatus);
     $result->setProperties($properties);
     $result->setMetadata($metadata);
     return $result;
 }
コード例 #7
0
 /**
  * Sets blob cacheControl.
  *
  * @param string $blobCacheControl value to use.
  * 
  * @return none.
  */
 public function setBlobCacheControl($blobCacheControl)
 {
     $this->_blobProperties->setCacheControl($blobCacheControl);
 }
コード例 #8
0
 /**
  * @covers WindowsAzure\Blob\Models\BlobProperties::setSequenceNumber
  * @covers WindowsAzure\Blob\Models\BlobProperties::getSequenceNumber
  */
 public function testSetSequenceNumber()
 {
     // Setup
     $expected = 123;
     $properties = new BlobProperties();
     $properties->setSequenceNumber($expected);
     // Test
     $properties->setSequenceNumber($expected);
     // Assert
     $this->assertEquals($expected, $properties->getSequenceNumber());
 }
コード例 #9
0
ファイル: AzureAdapter.php プロジェクト: mat33470/PFA
 /**
  * Builds the normalized output array from a Blob object.
  *
  * @param string         $path
  * @param BlobProperties $properties
  *
  * @return array
  */
 protected function normalizeBlobProperties($path, BlobProperties $properties)
 {
     if (substr($path, -1) === '/') {
         return ['type' => 'dir', 'path' => $this->removePathPrefix(rtrim($path, '/'))];
     }
     $path = $this->removePathPrefix($path);
     return ['path' => $path, 'timestamp' => (int) $properties->getLastModified()->format('U'), 'dirname' => Util::dirname($path), 'mimetype' => $properties->getContentType(), 'size' => $properties->getContentLength(), 'type' => 'file'];
 }