public function uploadPart()

in php/src/OSS.php [4370:4481]


    public function uploadPart($request, $runtime)
    {
        $request->validate();
        $runtime->validate();
        $_runtime = [
            'timeouted'      => 'retry',
            'readTimeout'    => Utils::defaultNumber($runtime->readTimeout, $this->_readTimeout),
            'connectTimeout' => Utils::defaultNumber($runtime->connectTimeout, $this->_connectTimeout),
            'localAddr'      => Utils::defaultString($runtime->localAddr, $this->_localAddr),
            'httpProxy'      => Utils::defaultString($runtime->httpProxy, $this->_httpProxy),
            'httpsProxy'     => Utils::defaultString($runtime->httpsProxy, $this->_httpsProxy),
            'noProxy'        => Utils::defaultString($runtime->noProxy, $this->_noProxy),
            'socks5Proxy'    => Utils::defaultString($runtime->socks5Proxy, $this->_socks5Proxy),
            'socks5NetWork'  => Utils::defaultString($runtime->socks5NetWork, $this->_socks5NetWork),
            'maxIdleConns'   => Utils::defaultNumber($runtime->maxIdleConns, $this->_maxIdleConns),
            'retry'          => [
                'retryable'   => $runtime->autoretry,
                'maxAttempts' => Utils::defaultNumber($runtime->maxAttempts, 3),
            ],
            'backoff' => [
                'policy' => Utils::defaultString($runtime->backoffPolicy, 'no'),
                'period' => Utils::defaultNumber($runtime->backoffPeriod, 1),
            ],
            'ignoreSSL' => $runtime->ignoreSSL,
        ];
        $_lastRequest   = null;
        $_lastException = null;
        $_now           = time();
        $_retryTimes    = 0;
        while (Tea::allowRetry(@$_runtime['retry'], $_retryTimes, $_now)) {
            if ($_retryTimes > 0) {
                $_backoffTime = Tea::getBackoffTime(@$_runtime['backoff'], $_retryTimes);
                if ($_backoffTime > 0) {
                    Tea::sleep($_backoffTime);
                }
            }
            $_retryTimes = $_retryTimes + 1;

            try {
                $_request           = new Request();
                $ctx                = [];
                $accessKeyId        = $this->_credential->getAccessKeyId();
                $accessKeySecret    = $this->_credential->getAccessKeySecret();
                $token              = $this->_credential->getSecurityToken();
                $_request->protocol = $this->_protocol;
                $_request->method   = 'PUT';
                $_request->pathname = '/' . $request->objectName . '';
                $_request->headers  = [
                    'host'       => OSSUtils::getHost($request->bucketName, $this->_regionId, $this->_endpoint, $this->_hostModel),
                    'date'       => Utils::getDateUTCString(),
                    'user-agent' => $this->getUserAgent(),
                ];
                if (!Utils::empty_($token)) {
                    $_request->headers['x-oss-security-token'] = $token;
                }
                $_request->query                    = Utils::stringifyMapValue(Tea::merge($request->filter));
                $_request->body                     = OSSUtils::inject($request->body, $ctx);
                $_request->headers['authorization'] = OSSUtils::getSignature($_request, $request->bucketName, $accessKeyId, $accessKeySecret, $this->_signatureVersion, $this->_addtionalHeaders);
                $_lastRequest                       = $_request;
                $_response                          = Tea::send($_request, $_runtime);
                $respMap                            = null;
                $bodyStr                            = null;
                if (Utils::is4xx($_response->statusCode) || Utils::is5xx($_response->statusCode)) {
                    $bodyStr = Utils::readAsString($_response->body);
                    $respMap = OSSUtils::getErrMessage($bodyStr);

                    throw new TeaError([
                        'code'    => @$respMap['Code'],
                        'message' => @$respMap['Message'],
                        'data'    => [
                            'httpCode'  => $_response->statusCode,
                            'requestId' => @$respMap['RequestId'],
                            'hostId'    => @$respMap['HostId'],
                        ],
                    ]);
                }
                if ($this->_isEnableCrc && !Utils::equalString(@$ctx['crc'], @$_response->headers['x-oss-hash-crc64ecma'])) {
                    throw new TeaError([
                        'code' => 'CrcNotMatched',
                        'data' => [
                            'clientCrc' => @$ctx['crc'],
                            'serverCrc' => @$_response->headers['x-oss-hash-crc64ecma'],
                        ],
                    ]);
                }
                if ($this->_isEnableMD5 && !Utils::equalString(@$ctx['md5'], @$_response->headers['content-md5'])) {
                    throw new TeaError([
                        'code' => 'MD5NotMatched',
                        'data' => [
                            'clientMD5' => @$ctx['md5'],
                            'serverMD5' => @$_response->headers['content-md5'],
                        ],
                    ]);
                }

                return UploadPartResponse::fromMap(Tea::merge($_response->headers));
            } catch (Exception $e) {
                if (!($e instanceof TeaError)) {
                    $e = new TeaError([], $e->getMessage(), $e->getCode(), $e);
                }
                if (Tea::isRetryable($e)) {
                    $_lastException = $e;

                    continue;
                }

                throw $e;
            }
        }

        throw new TeaUnableRetryError($_lastRequest, $_lastException);
    }