ListMultipartUploadResult.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace OSS\Result;
  3. use OSS\Core\OssUtil;
  4. use OSS\Model\ListMultipartUploadInfo;
  5. use OSS\Model\UploadInfo;
  6. /**
  7. * Class ListMultipartUploadResult
  8. * @package OSS\Result
  9. */
  10. class ListMultipartUploadResult extends Result
  11. {
  12. /**
  13. * Parse the return data from the ListMultipartUpload interface
  14. *
  15. * @return ListMultipartUploadInfo
  16. */
  17. protected function parseDataFromResponse()
  18. {
  19. $content = $this->rawResponse->body;
  20. $xml = simplexml_load_string($content);
  21. $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : "";
  22. $bucket = isset($xml->Bucket) ? strval($xml->Bucket) : "";
  23. $keyMarker = isset($xml->KeyMarker) ? strval($xml->KeyMarker) : "";
  24. $keyMarker = OssUtil::decodeKey($keyMarker, $encodingType);
  25. $uploadIdMarker = isset($xml->UploadIdMarker) ? strval($xml->UploadIdMarker) : "";
  26. $nextKeyMarker = isset($xml->NextKeyMarker) ? strval($xml->NextKeyMarker) : "";
  27. $nextKeyMarker = OssUtil::decodeKey($nextKeyMarker, $encodingType);
  28. $nextUploadIdMarker = isset($xml->NextUploadIdMarker) ? strval($xml->NextUploadIdMarker) : "";
  29. $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : "";
  30. $delimiter = OssUtil::decodeKey($delimiter, $encodingType);
  31. $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : "";
  32. $prefix = OssUtil::decodeKey($prefix, $encodingType);
  33. $maxUploads = isset($xml->MaxUploads) ? intval($xml->MaxUploads) : 0;
  34. $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : "";
  35. $listUpload = array();
  36. if (isset($xml->Upload)) {
  37. foreach ($xml->Upload as $upload) {
  38. $key = isset($upload->Key) ? strval($upload->Key) : "";
  39. $key = OssUtil::decodeKey($key, $encodingType);
  40. $uploadId = isset($upload->UploadId) ? strval($upload->UploadId) : "";
  41. $initiated = isset($upload->Initiated) ? strval($upload->Initiated) : "";
  42. $listUpload[] = new UploadInfo($key, $uploadId, $initiated);
  43. }
  44. }
  45. return new ListMultipartUploadInfo($bucket, $keyMarker, $uploadIdMarker,
  46. $nextKeyMarker, $nextUploadIdMarker,
  47. $delimiter, $prefix, $maxUploads, $isTruncated, $listUpload);
  48. }
  49. }