src/BaiduBce/Services/Bos/BosClient.php
public function uploadPart(
        $bucketName,
        $key,
        $uploadId,
        $partNumber,
        $contentLength,
        $contentMd5,
        $data,
        $options = array()
    ) {
        if (empty($bucketName)) {
            throw new \InvalidArgumentException(
                '$bucketName should not be empty or null.'
            );
        }
        if (empty($key)) {
            throw new \InvalidArgumentException(
                '$key should not be empty or null.'
            );
        }
        if (!is_int($contentLength) && !is_long($contentLength)) {
            throw new \InvalidArgumentException(
                '$contentLength should be int or long.'
            );
        }
        if ($partNumber < BosClient::MIN_PART_NUMBER
            || $partNumber > BosClient::MAX_PART_NUMBER
        ) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Invalid $partNumber %d. The valid range is from %d to %d.',
                    $partNumber,
                    BosClient::MIN_PART_NUMBER,
                    BosClient::MAX_PART_NUMBER
                )
            );
        }

        if ($contentMd5 === null) {
            throw new \InvalidArgumentException(
                '$contentMd5 should not be null.'
            );
        }

        $this->checkData($data);

        list($config) = $this->parseOptions($options, BosOptions::CONFIG);

        $headers = array();
        $headers[HttpHeaders::CONTENT_MD5] = $contentMd5;
        $headers[HttpHeaders::CONTENT_LENGTH] = $contentLength;
        $headers[HttpHeaders::CONTENT_TYPE] = HttpContentTypes::OCTET_STREAM;

        return $this->sendRequest(
            HttpMethod::PUT,
            array(
                BosOptions::CONFIG => $config,
                'bucket_name' => $bucketName,
                'key' => $key,
                'body' => $data,
                'params' => array(
                    'partNumber' => $partNumber,
                    'uploadId' => $uploadId
                ),
                'headers' => $headers,
            )
        );
    }
public function uploadPart(
        $bucketName,
        $key,
        $uploadId,
        $partNumber,
        $contentLength,
        $contentMd5,
        $data,
        $options = array()
    ) {
        if (empty($bucketName)) {
            throw new \InvalidArgumentException(
                '$bucketName should not be empty or null.'
            );
        }
        if (empty($key)) {
            throw new \InvalidArgumentException(
                '$key should not be empty or null.'
            );
        }
        if (!is_int($contentLength) && !is_long($contentLength)) {
            throw new \InvalidArgumentException(
                '$contentLength should be int or long.'
            );
        }
        if ($partNumber < BosClient::MIN_PART_NUMBER
            || $partNumber > BosClient::MAX_PART_NUMBER
        ) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Invalid $partNumber %d. The valid range is from %d to %d.',
                    $partNumber,
                    BosClient::MIN_PART_NUMBER,
                    BosClient::MAX_PART_NUMBER
                )
            );
        }

        if ($contentMd5 === null) {
            throw new \InvalidArgumentException(
                '$contentMd5 should not be null.'
            );
        }

        $this->checkData($data);

        list($config) = $this->parseOptions($options, BosOptions::CONFIG);

        $headers = array();
        $headers[HttpHeaders::CONTENT_MD5] = $contentMd5;
        $headers[HttpHeaders::CONTENT_LENGTH] = $contentLength;
        $headers[HttpHeaders::CONTENT_TYPE] = HttpContentTypes::OCTET_STREAM;

        return $this->sendRequest(
            HttpMethod::PUT,
            array(
                BosOptions::CONFIG => $config,
                'bucket_name' => $bucketName,
                'key' => $key,
                'body' => $data,
                'params' => array(
                    'partNumber' => $partNumber,
                    'uploadId' => $uploadId
                ),
                'headers' => $headers,
            )
        );
    }
public function uploadPart ( $ bucketName , $ key , $ uploadId , $ partNumber , $ contentLength , $ contentMd5 , $ data , $ options = array ( ) ) { if ( empty ( $ bucketName ) ) { throw new \ InvalidArgumentException ( '$bucketName should not be empty or null.' ) ; } if ( empty ( $ key ) ) { throw new \ InvalidArgumentException ( '$key should not be empty or null.' ) ; } if ( ! is_int ( $ contentLength ) && ! is_long ( $ contentLength ) ) { throw new \ InvalidArgumentException ( '$contentLength should be int or long.' ) ; } if ( $ partNumber < BosClient :: MIN_PART_NUMBER || $ partNumber > BosClient :: MAX_PART_NUMBER ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid $partNumber %d. The valid range is from %d to %d.' , $ partNumber , BosClient :: MIN_PART_NUMBER , BosClient :: MAX_PART_NUMBER ) ) ; } if ( $ contentMd5 === null ) { throw new \ InvalidArgumentException ( '$contentMd5 should not be null.' ) ; } $ this -> checkData ( $ data ) ; list ( $ config ) = $ this -> parseOptions ( $ options , BosOptions :: CONFIG ) ; $ headers = array ( ) ; $ headers [ HttpHeaders :: CONTENT_MD5 ] = $ contentMd5 ; $ headers [ HttpHeaders :: CONTENT_LENGTH ] = $ contentLength ; $ headers [ HttpHeaders :: CONTENT_TYPE ] = HttpContentTypes :: OCTET_STREAM ; return $ this -> sendRequest ( HttpMethod :: PUT , array ( BosOptions :: CONFIG => $ config , 'bucket_name' => $ bucketName , 'key' => $ key , 'body' => $ data , 'params' => array ( 'partNumber' => $ partNumber , 'uploadId' => $ uploadId ) , 'headers' => $ headers , ) ) ; }
Upload a part from a file handle

@param string $bucketName The bucket name.
@param string $key The object path.
@param string $uploadId The uploadId returned by initiateMultipartUpload.
@param int $partNumber The part index, 1-based.
@param int $contentLength The uploaded part size.
@param string $contentMd5 The part md5 check sum.
@param string $data The file pointer.
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.

@return mixed
Upload a part from a file handle