ListPartsResult.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace OSS\Result;
  3. use OSS\Model\ListPartsInfo;
  4. use OSS\Model\PartInfo;
  5. /**
  6. * Class ListPartsResult
  7. * @package OSS\Result
  8. */
  9. class ListPartsResult extends Result
  10. {
  11. /**
  12. * Parse the xml data returned by the ListParts interface
  13. *
  14. * @return ListPartsInfo
  15. */
  16. protected function parseDataFromResponse()
  17. {
  18. $content = $this->rawResponse->body;
  19. $xml = simplexml_load_string($content);
  20. $bucket = isset($xml->Bucket) ? strval($xml->Bucket) : "";
  21. $key = isset($xml->Key) ? strval($xml->Key) : "";
  22. $uploadId = isset($xml->UploadId) ? strval($xml->UploadId) : "";
  23. $nextPartNumberMarker = isset($xml->NextPartNumberMarker) ? intval($xml->NextPartNumberMarker) : "";
  24. $maxParts = isset($xml->MaxParts) ? intval($xml->MaxParts) : "";
  25. $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : "";
  26. $partList = array();
  27. if (isset($xml->Part)) {
  28. foreach ($xml->Part as $part) {
  29. $partNumber = isset($part->PartNumber) ? intval($part->PartNumber) : "";
  30. $lastModified = isset($part->LastModified) ? strval($part->LastModified) : "";
  31. $eTag = isset($part->ETag) ? strval($part->ETag) : "";
  32. $size = isset($part->Size) ? intval($part->Size) : "";
  33. $partList[] = new PartInfo($partNumber, $lastModified, $eTag, $size);
  34. }
  35. }
  36. return new ListPartsInfo($bucket, $key, $uploadId, $nextPartNumberMarker, $maxParts, $isTruncated, $partList);
  37. }
  38. }