/**
  * 解析从ListMultipartUpload接口的返回数据
  *
  * @return ListMultipartUploadInfo
  */
 protected function parseDataFromResponse()
 {
     $content = $this->rawResponse->body;
     $xml = simplexml_load_string($content);
     $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : "";
     $bucket = isset($xml->Bucket) ? strval($xml->Bucket) : "";
     $keyMarker = isset($xml->KeyMarker) ? strval($xml->KeyMarker) : "";
     $keyMarker = OssUtil::decodeKey($keyMarker, $encodingType);
     $uploadIdMarker = isset($xml->UploadIdMarker) ? strval($xml->UploadIdMarker) : "";
     $nextKeyMarker = isset($xml->NextKeyMarker) ? strval($xml->NextKeyMarker) : "";
     $nextKeyMarker = OssUtil::decodeKey($nextKeyMarker, $encodingType);
     $nextUploadIdMarker = isset($xml->NextUploadIdMarker) ? strval($xml->NextUploadIdMarker) : "";
     $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : "";
     $delimiter = OssUtil::decodeKey($delimiter, $encodingType);
     $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : "";
     $prefix = OssUtil::decodeKey($prefix, $encodingType);
     $maxUploads = isset($xml->MaxUploads) ? intval($xml->MaxUploads) : 0;
     $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : "";
     $listUpload = array();
     if (isset($xml->Upload)) {
         foreach ($xml->Upload as $upload) {
             $key = isset($upload->Key) ? strval($upload->Key) : "";
             $key = OssUtil::decodeKey($key, $encodingType);
             $uploadId = isset($upload->UploadId) ? strval($upload->UploadId) : "";
             $initiated = isset($upload->Initiated) ? strval($upload->Initiated) : "";
             $listUpload[] = new UploadInfo($key, $uploadId, $initiated);
         }
     }
     return new ListMultipartUploadInfo($bucket, $keyMarker, $uploadIdMarker, $nextKeyMarker, $nextUploadIdMarker, $delimiter, $prefix, $maxUploads, $isTruncated, $listUpload);
 }
 private function parsePrefixList($xml, $encodingType)
 {
     $retList = array();
     if (isset($xml->CommonPrefixes)) {
         foreach ($xml->CommonPrefixes as $commonPrefix) {
             $prefix = isset($commonPrefix->Prefix) ? strval($commonPrefix->Prefix) : "";
             $prefix = OssUtil::decodeKey($prefix, $encodingType);
             $retList[] = new PrefixInfo($prefix);
         }
     }
     return $retList;
 }
Example #3
0
 /**
  * 检查endpoint的种类
  * 如有有协议头,剥去协议头
  * 并且根据参数 is_cname 和endpoint本身,判定域名类型,是ip,cname,还是专有域或者官网域名
  *
  * @param string $endpoint
  * @param boolean $isCName
  * @return string 剥掉协议头的域名
  */
 private function checkEndpoint($endpoint, $isCName)
 {
     $ret_endpoint = null;
     if (strpos($endpoint, 'http://') === 0) {
         $ret_endpoint = substr($endpoint, strlen('http://'));
     } elseif (strpos($endpoint, 'https://') === 0) {
         $ret_endpoint = substr($endpoint, strlen('https://'));
         $this->useSSL = true;
     } else {
         $ret_endpoint = $endpoint;
     }
     if ($isCName) {
         $this->hostType = self::OSS_HOST_TYPE_CNAME;
     } elseif (OssUtil::isIPFormat($ret_endpoint)) {
         $this->hostType = self::OSS_HOST_TYPE_IP;
     } else {
         $this->hostType = self::OSS_HOST_TYPE_NORMAL;
     }
     return $ret_endpoint;
 }