lib/Beberlei/AzureBlobStorage/BlobClient.php
public function getBlockList($containerName = '', $blobName = '', $snapshotId = null, $leaseId = null, $type = 0)
    {
        Assertion::notEmpty($containerName, 'Container name is not specified');
        self::assertValidContainerName($containerName);
        Assertion::notEmpty($blobName, 'Blob name is not specified.');

        if ($type < 0 || $type > 2) {
            throw new BlobException('Invalid type of block list to retrieve.');
        }

        $blockListType = 'all';
        if ($type == 1) {
            $blockListType = 'committed';
        }
        if ($type == 2) {
            $blockListType = 'uncommitted';
        }

        $headers = array();
        if (!is_null($leaseId)) {
            $headers['x-ms-lease-id'] = $leaseId;
        }

        $query = array('comp' => 'blocklist', 'blocklisttype' => $blockListType);
        if (!is_null($snapshotId)) {
            $query['snapshot'] = $snapshotId;
        }

        $resourceName = self::createResourceName($containerName , $blobName);

        $response = $this->performRequest($resourceName, $query, 'GET', $headers, false, null, self::RESOURCE_BLOB, self::PERMISSION_READ);
        if ( ! $response->isSuccessful()) {
            throw new BlobException($this->getErrorMessage($response, 'Resource could not be accessed.'));
        }

        $blockList = $this->parseResponse($response);

        $returnValue = array();
        if ($blockList->CommittedBlocks) {
            foreach ($blockList->CommittedBlocks->Block as $block) {
                $returnValue['CommittedBlocks'][] = (object)array(
                    'Name' => (string)$block->Name,
                    'Size' => (string)$block->Size
                );
            }
        }
        if ($blockList->UncommittedBlocks)  {
            foreach ($blockList->UncommittedBlocks->Block as $block) {
                $returnValue['UncommittedBlocks'][] = (object)array(
                    'Name' => (string)$block->Name,
                    'Size' => (string)$block->Size
                );
            }
        }

        return $returnValue;
    }
public function getBlockList($containerName = '', $blobName = '', $snapshotId = null, $leaseId = null, $type = 0)
    {
        Assertion::notEmpty($containerName, 'Container name is not specified');
        self::assertValidContainerName($containerName);
        Assertion::notEmpty($blobName, 'Blob name is not specified.');

        if ($type < 0 || $type > 2) {
            throw new BlobException('Invalid type of block list to retrieve.');
        }

        $blockListType = 'all';
        if ($type == 1) {
            $blockListType = 'committed';
        }
        if ($type == 2) {
            $blockListType = 'uncommitted';
        }

        $headers = array();
        if (!is_null($leaseId)) {
            $headers['x-ms-lease-id'] = $leaseId;
        }

        $query = array('comp' => 'blocklist', 'blocklisttype' => $blockListType);
        if (!is_null($snapshotId)) {
            $query['snapshot'] = $snapshotId;
        }

        $resourceName = self::createResourceName($containerName , $blobName);

        $response = $this->performRequest($resourceName, $query, 'GET', $headers, false, null, self::RESOURCE_BLOB, self::PERMISSION_READ);
        if ( ! $response->isSuccessful()) {
            throw new BlobException($this->getErrorMessage($response, 'Resource could not be accessed.'));
        }

        $blockList = $this->parseResponse($response);

        $returnValue = array();
        if ($blockList->CommittedBlocks) {
            foreach ($blockList->CommittedBlocks->Block as $block) {
                $returnValue['CommittedBlocks'][] = (object)array(
                    'Name' => (string)$block->Name,
                    'Size' => (string)$block->Size
                );
            }
        }
        if ($blockList->UncommittedBlocks)  {
            foreach ($blockList->UncommittedBlocks->Block as $block) {
                $returnValue['UncommittedBlocks'][] = (object)array(
                    'Name' => (string)$block->Name,
                    'Size' => (string)$block->Size
                );
            }
        }

        return $returnValue;
    }
public function getBlockList ( $ containerName = '' , $ blobName = '' , $ snapshotId = null , $ leaseId = null , $ type = 0 ) { Assertion :: notEmpty ( $ containerName , 'Container name is not specified' ) ; self :: assertValidContainerName ( $ containerName ) ; Assertion :: notEmpty ( $ blobName , 'Blob name is not specified.' ) ; if ( $ type < 0 || $ type > 2 ) { throw new BlobException ( 'Invalid type of block list to retrieve.' ) ; } $ blockListType = 'all' ; if ( $ type == 1 ) { $ blockListType = 'committed' ; } if ( $ type == 2 ) { $ blockListType = 'uncommitted' ; } $ headers = array ( ) ; if ( ! is_null ( $ leaseId ) ) { $ headers [ 'x-ms-lease-id' ] = $ leaseId ; } $ query = array ( 'comp' => 'blocklist' , 'blocklisttype' => $ blockListType ) ; if ( ! is_null ( $ snapshotId ) ) { $ query [ 'snapshot' ] = $ snapshotId ; } $ resourceName = self :: createResourceName ( $ containerName , $ blobName ) ; $ response = $ this -> performRequest ( $ resourceName , $ query , 'GET' , $ headers , false , null , self :: RESOURCE_BLOB , self :: PERMISSION_READ ) ; if ( ! $ response -> isSuccessful ( ) ) { throw new BlobException ( $ this -> getErrorMessage ( $ response , 'Resource could not be accessed.' ) ) ; } $ blockList = $ this -> parseResponse ( $ response ) ; $ returnValue = array ( ) ; if ( $ blockList -> CommittedBlocks ) { foreach ( $ blockList -> CommittedBlocks -> Block as $ block ) { $ returnValue [ 'CommittedBlocks' ] [ ] = ( object ) array ( 'Name' => ( string ) $ block -> Name , 'Size' => ( string ) $ block -> Size ) ; } } if ( $ blockList -> UncommittedBlocks ) { foreach ( $ blockList -> UncommittedBlocks -> Block as $ block ) { $ returnValue [ 'UncommittedBlocks' ] [ ] = ( object ) array ( 'Name' => ( string ) $ block -> Name , 'Size' => ( string ) $ block -> Size ) ; } } return $ returnValue ; }
Get block list

@param string $containerName Container name
@param string $blobName      Blob name
@param string $snapshotId    Snapshot identifier
@param string $leaseId       Lease identifier
@param integer $type         Type of block list to retrieve. 0 = all, 1 = committed, 2 = uncommitted
@return array
@throws BlobException
Get block list