CompletedPart.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. namespace AsyncAws\S3\ValueObject;
  3. /**
  4. * Details of the parts that were uploaded.
  5. */
  6. final class CompletedPart
  7. {
  8. /**
  9. * Entity tag returned when the part was uploaded.
  10. */
  11. private $etag;
  12. /**
  13. * The base64-encoded, 32-bit CRC32 checksum of the object. This will only be present if it was uploaded with the
  14. * object. With multipart uploads, this may not be a checksum value of the object. For more information about how
  15. * checksums are calculated with multipart uploads, see Checking object integrity [^1] in the *Amazon S3 User Guide*.
  16. *
  17. * [^1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums
  18. */
  19. private $checksumCrc32;
  20. /**
  21. * The base64-encoded, 32-bit CRC32C checksum of the object. This will only be present if it was uploaded with the
  22. * object. With multipart uploads, this may not be a checksum value of the object. For more information about how
  23. * checksums are calculated with multipart uploads, see Checking object integrity [^1] in the *Amazon S3 User Guide*.
  24. *
  25. * [^1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums
  26. */
  27. private $checksumCrc32C;
  28. /**
  29. * The base64-encoded, 160-bit SHA-1 digest of the object. This will only be present if it was uploaded with the object.
  30. * With multipart uploads, this may not be a checksum value of the object. For more information about how checksums are
  31. * calculated with multipart uploads, see Checking object integrity [^1] in the *Amazon S3 User Guide*.
  32. *
  33. * [^1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums
  34. */
  35. private $checksumSha1;
  36. /**
  37. * The base64-encoded, 256-bit SHA-256 digest of the object. This will only be present if it was uploaded with the
  38. * object. With multipart uploads, this may not be a checksum value of the object. For more information about how
  39. * checksums are calculated with multipart uploads, see Checking object integrity [^1] in the *Amazon S3 User Guide*.
  40. *
  41. * [^1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums
  42. */
  43. private $checksumSha256;
  44. /**
  45. * Part number that identifies the part. This is a positive integer between 1 and 10,000.
  46. */
  47. private $partNumber;
  48. /**
  49. * @param array{
  50. * ETag?: null|string,
  51. * ChecksumCRC32?: null|string,
  52. * ChecksumCRC32C?: null|string,
  53. * ChecksumSHA1?: null|string,
  54. * ChecksumSHA256?: null|string,
  55. * PartNumber?: null|int,
  56. * } $input
  57. */
  58. public function __construct(array $input)
  59. {
  60. $this->etag = $input['ETag'] ?? null;
  61. $this->checksumCrc32 = $input['ChecksumCRC32'] ?? null;
  62. $this->checksumCrc32C = $input['ChecksumCRC32C'] ?? null;
  63. $this->checksumSha1 = $input['ChecksumSHA1'] ?? null;
  64. $this->checksumSha256 = $input['ChecksumSHA256'] ?? null;
  65. $this->partNumber = $input['PartNumber'] ?? null;
  66. }
  67. public static function create($input): self
  68. {
  69. return $input instanceof self ? $input : new self($input);
  70. }
  71. public function getChecksumCrc32(): ?string
  72. {
  73. return $this->checksumCrc32;
  74. }
  75. public function getChecksumCrc32C(): ?string
  76. {
  77. return $this->checksumCrc32C;
  78. }
  79. public function getChecksumSha1(): ?string
  80. {
  81. return $this->checksumSha1;
  82. }
  83. public function getChecksumSha256(): ?string
  84. {
  85. return $this->checksumSha256;
  86. }
  87. public function getEtag(): ?string
  88. {
  89. return $this->etag;
  90. }
  91. public function getPartNumber(): ?int
  92. {
  93. return $this->partNumber;
  94. }
  95. /**
  96. * @internal
  97. */
  98. public function requestBody(\DOMElement $node, \DOMDocument $document): void
  99. {
  100. if (null !== $v = $this->etag) {
  101. $node->appendChild($document->createElement('ETag', $v));
  102. }
  103. if (null !== $v = $this->checksumCrc32) {
  104. $node->appendChild($document->createElement('ChecksumCRC32', $v));
  105. }
  106. if (null !== $v = $this->checksumCrc32C) {
  107. $node->appendChild($document->createElement('ChecksumCRC32C', $v));
  108. }
  109. if (null !== $v = $this->checksumSha1) {
  110. $node->appendChild($document->createElement('ChecksumSHA1', $v));
  111. }
  112. if (null !== $v = $this->checksumSha256) {
  113. $node->appendChild($document->createElement('ChecksumSHA256', $v));
  114. }
  115. if (null !== $v = $this->partNumber) {
  116. $node->appendChild($document->createElement('PartNumber', $v));
  117. }
  118. }
  119. }