src/BaiduBce/Services/Bos/BosClient.php
public function putObject(
        $bucketName,
        $key,
        $data,
        $contentLength,
        $contentMd5,
        $options = array()
    ) {
        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 ($contentLength < 0) {
            throw new \InvalidArgumentException(
                '$contentLength should not be negative.'
            );
        }
        if (empty($contentMd5)) {
            throw new \InvalidArgumentException(
                '$contentMd5 should not be empty or null.'
            );
        }
        $this->checkData($data);

        $headers = array();
        $headers[HttpHeaders::CONTENT_MD5] = $contentMd5;
        $headers[HttpHeaders::CONTENT_LENGTH] = $contentLength;
        $this->populateRequestHeadersWithOptions($headers, $options);
        list($config) = $this->parseOptions($options, BosOptions::CONFIG);

        return $this->sendRequest(
            HttpMethod::PUT,
            array(
                BosOptions::CONFIG => $config,
                'bucket_name' => $bucketName,
                'key' => $key,
                'body' => $data,
                'headers' => $headers,
            )
        );
    }
public function putObject(
        $bucketName,
        $key,
        $data,
        $contentLength,
        $contentMd5,
        $options = array()
    ) {
        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 ($contentLength < 0) {
            throw new \InvalidArgumentException(
                '$contentLength should not be negative.'
            );
        }
        if (empty($contentMd5)) {
            throw new \InvalidArgumentException(
                '$contentMd5 should not be empty or null.'
            );
        }
        $this->checkData($data);

        $headers = array();
        $headers[HttpHeaders::CONTENT_MD5] = $contentMd5;
        $headers[HttpHeaders::CONTENT_LENGTH] = $contentLength;
        $this->populateRequestHeadersWithOptions($headers, $options);
        list($config) = $this->parseOptions($options, BosOptions::CONFIG);

        return $this->sendRequest(
            HttpMethod::PUT,
            array(
                BosOptions::CONFIG => $config,
                'bucket_name' => $bucketName,
                'key' => $key,
                'body' => $data,
                'headers' => $headers,
            )
        );
    }
public function putObject ( $ bucketName , $ key , $ data , $ contentLength , $ contentMd5 , $ options = array ( ) ) { 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 ( $ contentLength < 0 ) { throw new \ InvalidArgumentException ( '$contentLength should not be negative.' ) ; } if ( empty ( $ contentMd5 ) ) { throw new \ InvalidArgumentException ( '$contentMd5 should not be empty or null.' ) ; } $ this -> checkData ( $ data ) ; $ headers = array ( ) ; $ headers [ HttpHeaders :: CONTENT_MD5 ] = $ contentMd5 ; $ headers [ HttpHeaders :: CONTENT_LENGTH ] = $ contentLength ; $ this -> populateRequestHeadersWithOptions ( $ headers , $ options ) ; list ( $ config ) = $ this -> parseOptions ( $ options , BosOptions :: CONFIG ) ; return $ this -> sendRequest ( HttpMethod :: PUT , array ( BosOptions :: CONFIG => $ config , 'bucket_name' => $ bucketName , 'key' => $ key , 'body' => $ data , 'headers' => $ headers , ) ) ; }
Upload a object to one bucket
@param string $bucketName The bucket name.
@param string $key The object path.
@param string|resource $data The object content, which can be a string or a resource.
@param int $contentLength
@param string $contentMd5
@param mixed $options The optional bce configuration, which will overwrite the
default configuration that was passed while creating BosClient instance.
@return mixed
Upload a object to one bucket