lib/Beberlei/AzureBlobStorage/BlobClient.php
public function listBlobs($containerName = '', $prefix = '', $delimiter = '', $maxResults = null, $marker = null, $include = null, $currentResultCount = 0)
    {
        Assertion::notEmpty($containerName, 'Container name is not specified');
        self::assertValidContainerName($containerName);

        $query = array('restype' => 'container', 'comp' => 'list');
        if (!is_null($prefix)) {
            $query[] = 'prefix=' . $prefix;
        }
        if ($delimiter !== '') {
            $query['delimiter'] = $delimiter;
        }
        if (!is_null($maxResults)) {
            $query['maxresults'] = $maxResults;
        }
        if (!is_null($marker)) {
            $query['marker'] = $marker;
        }
        if (!is_null($include)) {
            $query['include'] = $include;
        }

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

        $blobs = array();

        $xmlBlobs = $this->parseResponse($response)->Blobs->Blob;
        if (!is_null($xmlBlobs)) {
            for ($i = 0; $i < count($xmlBlobs); $i++) {
                $properties = (array)$xmlBlobs[$i]->Properties;

                $blobs[] = new BlobInstance(
                $containerName,
                (string)$xmlBlobs[$i]->Name,
                (string)$xmlBlobs[$i]->Snapshot,
                (string)$properties['Etag'],
                (string)$properties['Last-Modified'],
                (string)$xmlBlobs[$i]->Url,
                (string)$properties['Content-Length'],
                (string)$properties['Content-Type'],
                (string)$properties['Content-Encoding'],
                (string)$properties['Content-Language'],
                (string)$properties['Cache-Control'],
                (string)$properties['BlobType'],
                (string)$properties['LeaseStatus'],
                false,
                $this->parseMetadataElement($xmlBlobs[$i])
                );
            }
        }

        $xmlBlobs = $this->parseResponse($response)->Blobs->BlobPrefix;

        if (!is_null($xmlBlobs)) {
            for ($i = 0; $i < count($xmlBlobs); $i++) {
                $blobs[] = new BlobInstance(
                $containerName,
                (string)$xmlBlobs[$i]->Name,
                null,
                    '',
                    '',
                    '',
                0,
                    '',
                    '',
                    '',
                    '',
                    '',
                    '',
                true,
                $this->parseMetadataElement($xmlBlobs[$i])
                );
            }
        }

        $xmlMarker = (string)$this->parseResponse($response)->NextMarker;
        $currentResultCount = $currentResultCount + count($blobs);
        if (!is_null($maxResults) && $currentResultCount < $maxResults) {
            if (!is_null($xmlMarker) && $xmlMarker != '') {
                $blobs = array_merge($blobs, $this->listBlobs($containerName, $prefix, $delimiter, $maxResults, $marker, $include, $currentResultCount));
            }
        }
        if (!is_null($maxResults) && count($blobs) > $maxResults) {
            $blobs = array_slice($blobs, 0, $maxResults);
        }

        return $blobs;
    }
public function listBlobs($containerName = '', $prefix = '', $delimiter = '', $maxResults = null, $marker = null, $include = null, $currentResultCount = 0)
    {
        Assertion::notEmpty($containerName, 'Container name is not specified');
        self::assertValidContainerName($containerName);

        $query = array('restype' => 'container', 'comp' => 'list');
        if (!is_null($prefix)) {
            $query[] = 'prefix=' . $prefix;
        }
        if ($delimiter !== '') {
            $query['delimiter'] = $delimiter;
        }
        if (!is_null($maxResults)) {
            $query['maxresults'] = $maxResults;
        }
        if (!is_null($marker)) {
            $query['marker'] = $marker;
        }
        if (!is_null($include)) {
            $query['include'] = $include;
        }

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

        $blobs = array();

        $xmlBlobs = $this->parseResponse($response)->Blobs->Blob;
        if (!is_null($xmlBlobs)) {
            for ($i = 0; $i < count($xmlBlobs); $i++) {
                $properties = (array)$xmlBlobs[$i]->Properties;

                $blobs[] = new BlobInstance(
                $containerName,
                (string)$xmlBlobs[$i]->Name,
                (string)$xmlBlobs[$i]->Snapshot,
                (string)$properties['Etag'],
                (string)$properties['Last-Modified'],
                (string)$xmlBlobs[$i]->Url,
                (string)$properties['Content-Length'],
                (string)$properties['Content-Type'],
                (string)$properties['Content-Encoding'],
                (string)$properties['Content-Language'],
                (string)$properties['Cache-Control'],
                (string)$properties['BlobType'],
                (string)$properties['LeaseStatus'],
                false,
                $this->parseMetadataElement($xmlBlobs[$i])
                );
            }
        }

        $xmlBlobs = $this->parseResponse($response)->Blobs->BlobPrefix;

        if (!is_null($xmlBlobs)) {
            for ($i = 0; $i < count($xmlBlobs); $i++) {
                $blobs[] = new BlobInstance(
                $containerName,
                (string)$xmlBlobs[$i]->Name,
                null,
                    '',
                    '',
                    '',
                0,
                    '',
                    '',
                    '',
                    '',
                    '',
                    '',
                true,
                $this->parseMetadataElement($xmlBlobs[$i])
                );
            }
        }

        $xmlMarker = (string)$this->parseResponse($response)->NextMarker;
        $currentResultCount = $currentResultCount + count($blobs);
        if (!is_null($maxResults) && $currentResultCount < $maxResults) {
            if (!is_null($xmlMarker) && $xmlMarker != '') {
                $blobs = array_merge($blobs, $this->listBlobs($containerName, $prefix, $delimiter, $maxResults, $marker, $include, $currentResultCount));
            }
        }
        if (!is_null($maxResults) && count($blobs) > $maxResults) {
            $blobs = array_slice($blobs, 0, $maxResults);
        }

        return $blobs;
    }
public function listBlobs ( $ containerName = '' , $ prefix = '' , $ delimiter = '' , $ maxResults = null , $ marker = null , $ include = null , $ currentResultCount = 0 ) { Assertion :: notEmpty ( $ containerName , 'Container name is not specified' ) ; self :: assertValidContainerName ( $ containerName ) ; $ query = array ( 'restype' => 'container' , 'comp' => 'list' ) ; if ( ! is_null ( $ prefix ) ) { $ query [ ] = 'prefix=' . $ prefix ; } if ( $ delimiter !== '' ) { $ query [ 'delimiter' ] = $ delimiter ; } if ( ! is_null ( $ maxResults ) ) { $ query [ 'maxresults' ] = $ maxResults ; } if ( ! is_null ( $ marker ) ) { $ query [ 'marker' ] = $ marker ; } if ( ! is_null ( $ include ) ) { $ query [ 'include' ] = $ include ; } $ response = $ this -> performRequest ( $ containerName , $ query , 'GET' , array ( ) , false , null , self :: RESOURCE_BLOB , self :: PERMISSION_LIST ) ; if ( ! $ response -> isSuccessful ( ) ) { throw new BlobException ( $ this -> getErrorMessage ( $ response , 'Resource could not be accessed.' ) ) ; } $ blobs = array ( ) ; $ xmlBlobs = $ this -> parseResponse ( $ response ) -> Blobs -> Blob ; if ( ! is_null ( $ xmlBlobs ) ) { for ( $ i = 0 ; $ i < count ( $ xmlBlobs ) ; $ i ++ ) { $ properties = ( array ) $ xmlBlobs [ $ i ] -> Properties ; $ blobs [ ] = new BlobInstance ( $ containerName , ( string ) $ xmlBlobs [ $ i ] -> Name , ( string ) $ xmlBlobs [ $ i ] -> Snapshot , ( string ) $ properties [ 'Etag' ] , ( string ) $ properties [ 'Last-Modified' ] , ( string ) $ xmlBlobs [ $ i ] -> Url , ( string ) $ properties [ 'Content-Length' ] , ( string ) $ properties [ 'Content-Type' ] , ( string ) $ properties [ 'Content-Encoding' ] , ( string ) $ properties [ 'Content-Language' ] , ( string ) $ properties [ 'Cache-Control' ] , ( string ) $ properties [ 'BlobType' ] , ( string ) $ properties [ 'LeaseStatus' ] , false , $ this -> parseMetadataElement ( $ xmlBlobs [ $ i ] ) ) ; } } $ xmlBlobs = $ this -> parseResponse ( $ response ) -> Blobs -> BlobPrefix ; if ( ! is_null ( $ xmlBlobs ) ) { for ( $ i = 0 ; $ i < count ( $ xmlBlobs ) ; $ i ++ ) { $ blobs [ ] = new BlobInstance ( $ containerName , ( string ) $ xmlBlobs [ $ i ] -> Name , null , '' , '' , '' , 0 , '' , '' , '' , '' , '' , '' , true , $ this -> parseMetadataElement ( $ xmlBlobs [ $ i ] ) ) ; } } $ xmlMarker = ( string ) $ this -> parseResponse ( $ response ) -> NextMarker ; $ currentResultCount = $ currentResultCount + count ( $ blobs ) ; if ( ! is_null ( $ maxResults ) && $ currentResultCount < $ maxResults ) { if ( ! is_null ( $ xmlMarker ) && $ xmlMarker != '' ) { $ blobs = array_merge ( $ blobs , $ this -> listBlobs ( $ containerName , $ prefix , $ delimiter , $ maxResults , $ marker , $ include , $ currentResultCount ) ) ; } } if ( ! is_null ( $ maxResults ) && count ( $ blobs ) > $ maxResults ) { $ blobs = array_slice ( $ blobs , 0 , $ maxResults ) ; } return $ blobs ; }
List blobs

@param string $containerName Container name
@param string $prefix     Optional. Filters the results to return only blobs whose name begins with the specified prefix.
@param string $delimiter  Optional. Delimiter, i.e. '/', for specifying folder hierarchy
@param int    $maxResults Optional. Specifies the maximum number of blobs to return per call to Azure storage. This does NOT affect list size returned by this function. (maximum: 5000)
@param string $marker     Optional string value that identifies the portion of the list to be returned with the next list operation.
@param string $include    Optional. Specifies that the response should include one or more of the following subsets: '', 'metadata', 'snapshots', 'uncommittedblobs'). Multiple values can be added separated with a comma (,)
@param int    $currentResultCount Current result count (internal use)
@return array
@throws BlobException
List blobs