src/BaiduBce/Services/Bos/BosClient.php
public function getObject(
        $bucketName,
        $key,
        $outputStream,
        $options = array()
    ) {
        list($config, $range) = $this->parseOptions(
            $options,
            BosOptions::CONFIG,
            BosOptions::RANGE
        );
        $headers = array();
        if ($range !== null) {
            switch(gettype($range)) {
                case 'array':
                    if (!isset($range[0]) || !(is_int($range[0]) || is_long($range[0]))) {
                        throw new \InvalidArgumentException(
                            'range[0] is not defined.'
                        );
                    }
                    if (!isset($range[1]) || !(is_int($range[1]) || is_long($range[1]))) {
                        throw new \InvalidArgumentException(
                            'range[1] is not defined.'
                        );
                    }
                    $range = sprintf('%d-%d', $range[0], $range[1]);
                    break;
                case 'string':
                    break;
                default:
                    throw new \InvalidArgumentException(
                        'Option "range" should be either an array of two '
                        . 'integers or a string'
                    );
            }
            $headers[HttpHeaders::RANGE] = sprintf('bytes=%s', $range);
        }

        $response = $this->sendRequest(
            HttpMethod::GET,
            array(
                BosOptions::CONFIG => $config,
                'bucket_name' => $bucketName,
                'key' => $key,
                'headers' => $headers,
                'outputStream' => $outputStream,
                'parseUserMetadata' => true
            )
        );
        return $response;
    }
public function getObject(
        $bucketName,
        $key,
        $outputStream,
        $options = array()
    ) {
        list($config, $range) = $this->parseOptions(
            $options,
            BosOptions::CONFIG,
            BosOptions::RANGE
        );
        $headers = array();
        if ($range !== null) {
            switch(gettype($range)) {
                case 'array':
                    if (!isset($range[0]) || !(is_int($range[0]) || is_long($range[0]))) {
                        throw new \InvalidArgumentException(
                            'range[0] is not defined.'
                        );
                    }
                    if (!isset($range[1]) || !(is_int($range[1]) || is_long($range[1]))) {
                        throw new \InvalidArgumentException(
                            'range[1] is not defined.'
                        );
                    }
                    $range = sprintf('%d-%d', $range[0], $range[1]);
                    break;
                case 'string':
                    break;
                default:
                    throw new \InvalidArgumentException(
                        'Option "range" should be either an array of two '
                        . 'integers or a string'
                    );
            }
            $headers[HttpHeaders::RANGE] = sprintf('bytes=%s', $range);
        }

        $response = $this->sendRequest(
            HttpMethod::GET,
            array(
                BosOptions::CONFIG => $config,
                'bucket_name' => $bucketName,
                'key' => $key,
                'headers' => $headers,
                'outputStream' => $outputStream,
                'parseUserMetadata' => true
            )
        );
        return $response;
    }
public function getObject ( $ bucketName , $ key , $ outputStream , $ options = array ( ) ) { list ( $ config , $ range ) = $ this -> parseOptions ( $ options , BosOptions :: CONFIG , BosOptions :: RANGE ) ; $ headers = array ( ) ; if ( $ range !== null ) { switch ( gettype ( $ range ) ) { case 'array' : if ( ! isset ( $ range [ 0 ] ) || ! ( is_int ( $ range [ 0 ] ) || is_long ( $ range [ 0 ] ) ) ) { throw new \ InvalidArgumentException ( 'range[0] is not defined.' ) ; } if ( ! isset ( $ range [ 1 ] ) || ! ( is_int ( $ range [ 1 ] ) || is_long ( $ range [ 1 ] ) ) ) { throw new \ InvalidArgumentException ( 'range[1] is not defined.' ) ; } $ range = sprintf ( '%d-%d' , $ range [ 0 ] , $ range [ 1 ] ) ; break ; case 'string' : break ; default : throw new \ InvalidArgumentException ( 'Option "range" should be either an array of two ' . 'integers or a string' ) ; } $ headers [ HttpHeaders :: RANGE ] = sprintf ( 'bytes=%s' , $ range ) ; } $ response = $ this -> sendRequest ( HttpMethod :: GET , array ( BosOptions :: CONFIG => $ config , 'bucket_name' => $ bucketName , 'key' => $ key , 'headers' => $ headers , 'outputStream' => $ outputStream , 'parseUserMetadata' => true ) ) ; return $ response ; }
Get the object from a bucket.

@param string $bucketName The bucket name.
@param string $key The object path.
@param resource $outputStream
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed
Get the object from a bucket .