CopyObjectRequest.php 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222
  1. <?php
  2. namespace AsyncAws\S3\Input;
  3. use AsyncAws\Core\Exception\InvalidArgument;
  4. use AsyncAws\Core\Input;
  5. use AsyncAws\Core\Request;
  6. use AsyncAws\Core\Stream\StreamFactory;
  7. use AsyncAws\S3\Enum\ChecksumAlgorithm;
  8. use AsyncAws\S3\Enum\MetadataDirective;
  9. use AsyncAws\S3\Enum\ObjectCannedACL;
  10. use AsyncAws\S3\Enum\ObjectLockLegalHoldStatus;
  11. use AsyncAws\S3\Enum\ObjectLockMode;
  12. use AsyncAws\S3\Enum\RequestPayer;
  13. use AsyncAws\S3\Enum\ServerSideEncryption;
  14. use AsyncAws\S3\Enum\StorageClass;
  15. use AsyncAws\S3\Enum\TaggingDirective;
  16. final class CopyObjectRequest extends Input
  17. {
  18. /**
  19. * The canned ACL to apply to the object.
  20. *
  21. * This action is not supported by Amazon S3 on Outposts.
  22. *
  23. * @var ObjectCannedACL::*|null
  24. */
  25. private $acl;
  26. /**
  27. * The name of the destination bucket.
  28. *
  29. * When using this action with an access point, you must direct requests to the access point hostname. The access point
  30. * hostname takes the form *AccessPointName*-*AccountId*.s3-accesspoint.*Region*.amazonaws.com. When using this action
  31. * with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket
  32. * name. For more information about access point ARNs, see Using access points [^1] in the *Amazon S3 User Guide*.
  33. *
  34. * When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3
  35. * on Outposts hostname takes the form `*AccessPointName*-*AccountId*.*outpostID*.s3-outposts.*Region*.amazonaws.com`.
  36. * When you use this action with S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts access
  37. * point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts
  38. * [^2] in the *Amazon S3 User Guide*.
  39. *
  40. * [^1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html
  41. * [^2]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html
  42. *
  43. * @required
  44. *
  45. * @var string|null
  46. */
  47. private $bucket;
  48. /**
  49. * Specifies caching behavior along the request/reply chain.
  50. *
  51. * @var string|null
  52. */
  53. private $cacheControl;
  54. /**
  55. * Indicates the algorithm you want Amazon S3 to use to create the checksum for the object. For more information, see
  56. * Checking object integrity [^1] in the *Amazon S3 User Guide*.
  57. *
  58. * [^1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html
  59. *
  60. * @var ChecksumAlgorithm::*|null
  61. */
  62. private $checksumAlgorithm;
  63. /**
  64. * Specifies presentational information for the object.
  65. *
  66. * @var string|null
  67. */
  68. private $contentDisposition;
  69. /**
  70. * Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to
  71. * obtain the media-type referenced by the Content-Type header field.
  72. *
  73. * @var string|null
  74. */
  75. private $contentEncoding;
  76. /**
  77. * The language the content is in.
  78. *
  79. * @var string|null
  80. */
  81. private $contentLanguage;
  82. /**
  83. * A standard MIME type describing the format of the object data.
  84. *
  85. * @var string|null
  86. */
  87. private $contentType;
  88. /**
  89. * Specifies the source object for the copy operation. You specify the value in one of two formats, depending on whether
  90. * you want to access the source object through an access point [^1]:.
  91. *
  92. * - For objects not accessed through an access point, specify the name of the source bucket and the key of the source
  93. * object, separated by a slash (/). For example, to copy the object `reports/january.pdf` from the bucket
  94. * `awsexamplebucket`, use `awsexamplebucket/reports/january.pdf`. The value must be URL-encoded.
  95. * - For objects accessed through access points, specify the Amazon Resource Name (ARN) of the object as accessed
  96. * through the access point, in the format
  97. * `arn:aws:s3:<Region>:<account-id>:accesspoint/<access-point-name>/object/<key>`. For
  98. * example, to copy the object `reports/january.pdf` through access point `my-access-point` owned by account
  99. * `123456789012` in Region `us-west-2`, use the URL encoding of
  100. * `arn:aws:s3:us-west-2:123456789012:accesspoint/my-access-point/object/reports/january.pdf`. The value must be URL
  101. * encoded.
  102. *
  103. * > Amazon S3 supports copy operations using access points only when the source and destination buckets are in the
  104. * > same Amazon Web Services Region.
  105. *
  106. * Alternatively, for objects accessed through Amazon S3 on Outposts, specify the ARN of the object as accessed in the
  107. * format `arn:aws:s3-outposts:<Region>:<account-id>:outpost/<outpost-id>/object/<key>`. For
  108. * example, to copy the object `reports/january.pdf` through outpost `my-outpost` owned by account `123456789012` in
  109. * Region `us-west-2`, use the URL encoding of
  110. * `arn:aws:s3-outposts:us-west-2:123456789012:outpost/my-outpost/object/reports/january.pdf`. The value must be
  111. * URL-encoded.
  112. *
  113. * To copy a specific version of an object, append `?versionId=<version-id>` to the value (for example,
  114. * `awsexamplebucket/reports/january.pdf?versionId=QUpfdndhfd8438MNFDN93jdnJFkdmqnh893`). If you don't specify a version
  115. * ID, Amazon S3 copies the latest version of the source object.
  116. *
  117. * [^1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-points.html
  118. *
  119. * @required
  120. *
  121. * @var string|null
  122. */
  123. private $copySource;
  124. /**
  125. * Copies the object if its entity tag (ETag) matches the specified tag.
  126. *
  127. * @var string|null
  128. */
  129. private $copySourceIfMatch;
  130. /**
  131. * Copies the object if it has been modified since the specified time.
  132. *
  133. * @var \DateTimeImmutable|null
  134. */
  135. private $copySourceIfModifiedSince;
  136. /**
  137. * Copies the object if its entity tag (ETag) is different than the specified ETag.
  138. *
  139. * @var string|null
  140. */
  141. private $copySourceIfNoneMatch;
  142. /**
  143. * Copies the object if it hasn't been modified since the specified time.
  144. *
  145. * @var \DateTimeImmutable|null
  146. */
  147. private $copySourceIfUnmodifiedSince;
  148. /**
  149. * The date and time at which the object is no longer cacheable.
  150. *
  151. * @var \DateTimeImmutable|null
  152. */
  153. private $expires;
  154. /**
  155. * Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.
  156. *
  157. * This action is not supported by Amazon S3 on Outposts.
  158. *
  159. * @var string|null
  160. */
  161. private $grantFullControl;
  162. /**
  163. * Allows grantee to read the object data and its metadata.
  164. *
  165. * This action is not supported by Amazon S3 on Outposts.
  166. *
  167. * @var string|null
  168. */
  169. private $grantRead;
  170. /**
  171. * Allows grantee to read the object ACL.
  172. *
  173. * This action is not supported by Amazon S3 on Outposts.
  174. *
  175. * @var string|null
  176. */
  177. private $grantReadAcp;
  178. /**
  179. * Allows grantee to write the ACL for the applicable object.
  180. *
  181. * This action is not supported by Amazon S3 on Outposts.
  182. *
  183. * @var string|null
  184. */
  185. private $grantWriteAcp;
  186. /**
  187. * The key of the destination object.
  188. *
  189. * @required
  190. *
  191. * @var string|null
  192. */
  193. private $key;
  194. /**
  195. * A map of metadata to store with the object in S3.
  196. *
  197. * @var array<string, string>|null
  198. */
  199. private $metadata;
  200. /**
  201. * Specifies whether the metadata is copied from the source object or replaced with metadata provided in the request.
  202. *
  203. * @var MetadataDirective::*|null
  204. */
  205. private $metadataDirective;
  206. /**
  207. * Specifies whether the object tag-set are copied from the source object or replaced with tag-set provided in the
  208. * request.
  209. *
  210. * @var TaggingDirective::*|null
  211. */
  212. private $taggingDirective;
  213. /**
  214. * The server-side encryption algorithm used when storing this object in Amazon S3 (for example, `AES256`, `aws:kms`,
  215. * `aws:kms:dsse`).
  216. *
  217. * @var ServerSideEncryption::*|null
  218. */
  219. private $serverSideEncryption;
  220. /**
  221. * By default, Amazon S3 uses the STANDARD Storage Class to store newly created objects. The STANDARD storage class
  222. * provides high durability and high availability. Depending on performance needs, you can specify a different Storage
  223. * Class. Amazon S3 on Outposts only uses the OUTPOSTS Storage Class. For more information, see Storage Classes [^1] in
  224. * the *Amazon S3 User Guide*.
  225. *
  226. * [^1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html
  227. *
  228. * @var StorageClass::*|null
  229. */
  230. private $storageClass;
  231. /**
  232. * If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or
  233. * to an external URL. Amazon S3 stores the value of this header in the object metadata. This value is unique to each
  234. * object and is not copied when using the `x-amz-metadata-directive` header. Instead, you may opt to provide this
  235. * header in combination with the directive.
  236. *
  237. * @var string|null
  238. */
  239. private $websiteRedirectLocation;
  240. /**
  241. * Specifies the algorithm to use to when encrypting the object (for example, AES256).
  242. *
  243. * @var string|null
  244. */
  245. private $sseCustomerAlgorithm;
  246. /**
  247. * Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data. This value is used to store
  248. * the object and then it is discarded; Amazon S3 does not store the encryption key. The key must be appropriate for use
  249. * with the algorithm specified in the `x-amz-server-side-encryption-customer-algorithm` header.
  250. *
  251. * @var string|null
  252. */
  253. private $sseCustomerKey;
  254. /**
  255. * Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a
  256. * message integrity check to ensure that the encryption key was transmitted without error.
  257. *
  258. * @var string|null
  259. */
  260. private $sseCustomerKeyMd5;
  261. /**
  262. * Specifies the KMS key ID to use for object encryption. All GET and PUT requests for an object protected by KMS will
  263. * fail if they're not made via SSL or using SigV4. For information about configuring any of the officially supported
  264. * Amazon Web Services SDKs and Amazon Web Services CLI, see Specifying the Signature Version in Request Authentication
  265. * [^1] in the *Amazon S3 User Guide*.
  266. *
  267. * [^1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
  268. *
  269. * @var string|null
  270. */
  271. private $sseKmsKeyId;
  272. /**
  273. * Specifies the Amazon Web Services KMS Encryption Context to use for object encryption. The value of this header is a
  274. * base64-encoded UTF-8 string holding JSON with the encryption context key-value pairs.
  275. *
  276. * @var string|null
  277. */
  278. private $sseKmsEncryptionContext;
  279. /**
  280. * Specifies whether Amazon S3 should use an S3 Bucket Key for object encryption with server-side encryption using Key
  281. * Management Service (KMS) keys (SSE-KMS). Setting this header to `true` causes Amazon S3 to use an S3 Bucket Key for
  282. * object encryption with SSE-KMS.
  283. *
  284. * Specifying this header with a COPY action doesn’t affect bucket-level settings for S3 Bucket Key.
  285. *
  286. * @var bool|null
  287. */
  288. private $bucketKeyEnabled;
  289. /**
  290. * Specifies the algorithm to use when decrypting the source object (for example, AES256).
  291. *
  292. * @var string|null
  293. */
  294. private $copySourceSseCustomerAlgorithm;
  295. /**
  296. * Specifies the customer-provided encryption key for Amazon S3 to use to decrypt the source object. The encryption key
  297. * provided in this header must be one that was used when the source object was created.
  298. *
  299. * @var string|null
  300. */
  301. private $copySourceSseCustomerKey;
  302. /**
  303. * Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a
  304. * message integrity check to ensure that the encryption key was transmitted without error.
  305. *
  306. * @var string|null
  307. */
  308. private $copySourceSseCustomerKeyMd5;
  309. /**
  310. * @var RequestPayer::*|null
  311. */
  312. private $requestPayer;
  313. /**
  314. * The tag-set for the object destination object this value must be used in conjunction with the `TaggingDirective`. The
  315. * tag-set must be encoded as URL Query parameters.
  316. *
  317. * @var string|null
  318. */
  319. private $tagging;
  320. /**
  321. * The Object Lock mode that you want to apply to the copied object.
  322. *
  323. * @var ObjectLockMode::*|null
  324. */
  325. private $objectLockMode;
  326. /**
  327. * The date and time when you want the copied object's Object Lock to expire.
  328. *
  329. * @var \DateTimeImmutable|null
  330. */
  331. private $objectLockRetainUntilDate;
  332. /**
  333. * Specifies whether you want to apply a legal hold to the copied object.
  334. *
  335. * @var ObjectLockLegalHoldStatus::*|null
  336. */
  337. private $objectLockLegalHoldStatus;
  338. /**
  339. * The account ID of the expected destination bucket owner. If the destination bucket is owned by a different account,
  340. * the request fails with the HTTP status code `403 Forbidden` (access denied).
  341. *
  342. * @var string|null
  343. */
  344. private $expectedBucketOwner;
  345. /**
  346. * The account ID of the expected source bucket owner. If the source bucket is owned by a different account, the request
  347. * fails with the HTTP status code `403 Forbidden` (access denied).
  348. *
  349. * @var string|null
  350. */
  351. private $expectedSourceBucketOwner;
  352. /**
  353. * @param array{
  354. * ACL?: ObjectCannedACL::*,
  355. * Bucket?: string,
  356. * CacheControl?: string,
  357. * ChecksumAlgorithm?: ChecksumAlgorithm::*,
  358. * ContentDisposition?: string,
  359. * ContentEncoding?: string,
  360. * ContentLanguage?: string,
  361. * ContentType?: string,
  362. * CopySource?: string,
  363. * CopySourceIfMatch?: string,
  364. * CopySourceIfModifiedSince?: \DateTimeImmutable|string,
  365. * CopySourceIfNoneMatch?: string,
  366. * CopySourceIfUnmodifiedSince?: \DateTimeImmutable|string,
  367. * Expires?: \DateTimeImmutable|string,
  368. * GrantFullControl?: string,
  369. * GrantRead?: string,
  370. * GrantReadACP?: string,
  371. * GrantWriteACP?: string,
  372. * Key?: string,
  373. * Metadata?: array<string, string>,
  374. * MetadataDirective?: MetadataDirective::*,
  375. * TaggingDirective?: TaggingDirective::*,
  376. * ServerSideEncryption?: ServerSideEncryption::*,
  377. * StorageClass?: StorageClass::*,
  378. * WebsiteRedirectLocation?: string,
  379. * SSECustomerAlgorithm?: string,
  380. * SSECustomerKey?: string,
  381. * SSECustomerKeyMD5?: string,
  382. * SSEKMSKeyId?: string,
  383. * SSEKMSEncryptionContext?: string,
  384. * BucketKeyEnabled?: bool,
  385. * CopySourceSSECustomerAlgorithm?: string,
  386. * CopySourceSSECustomerKey?: string,
  387. * CopySourceSSECustomerKeyMD5?: string,
  388. * RequestPayer?: RequestPayer::*,
  389. * Tagging?: string,
  390. * ObjectLockMode?: ObjectLockMode::*,
  391. * ObjectLockRetainUntilDate?: \DateTimeImmutable|string,
  392. * ObjectLockLegalHoldStatus?: ObjectLockLegalHoldStatus::*,
  393. * ExpectedBucketOwner?: string,
  394. * ExpectedSourceBucketOwner?: string,
  395. *
  396. * @region?: string,
  397. * } $input
  398. */
  399. public function __construct(array $input = [])
  400. {
  401. $this->acl = $input['ACL'] ?? null;
  402. $this->bucket = $input['Bucket'] ?? null;
  403. $this->cacheControl = $input['CacheControl'] ?? null;
  404. $this->checksumAlgorithm = $input['ChecksumAlgorithm'] ?? null;
  405. $this->contentDisposition = $input['ContentDisposition'] ?? null;
  406. $this->contentEncoding = $input['ContentEncoding'] ?? null;
  407. $this->contentLanguage = $input['ContentLanguage'] ?? null;
  408. $this->contentType = $input['ContentType'] ?? null;
  409. $this->copySource = $input['CopySource'] ?? null;
  410. $this->copySourceIfMatch = $input['CopySourceIfMatch'] ?? null;
  411. $this->copySourceIfModifiedSince = !isset($input['CopySourceIfModifiedSince']) ? null : ($input['CopySourceIfModifiedSince'] instanceof \DateTimeImmutable ? $input['CopySourceIfModifiedSince'] : new \DateTimeImmutable($input['CopySourceIfModifiedSince']));
  412. $this->copySourceIfNoneMatch = $input['CopySourceIfNoneMatch'] ?? null;
  413. $this->copySourceIfUnmodifiedSince = !isset($input['CopySourceIfUnmodifiedSince']) ? null : ($input['CopySourceIfUnmodifiedSince'] instanceof \DateTimeImmutable ? $input['CopySourceIfUnmodifiedSince'] : new \DateTimeImmutable($input['CopySourceIfUnmodifiedSince']));
  414. $this->expires = !isset($input['Expires']) ? null : ($input['Expires'] instanceof \DateTimeImmutable ? $input['Expires'] : new \DateTimeImmutable($input['Expires']));
  415. $this->grantFullControl = $input['GrantFullControl'] ?? null;
  416. $this->grantRead = $input['GrantRead'] ?? null;
  417. $this->grantReadAcp = $input['GrantReadACP'] ?? null;
  418. $this->grantWriteAcp = $input['GrantWriteACP'] ?? null;
  419. $this->key = $input['Key'] ?? null;
  420. $this->metadata = $input['Metadata'] ?? null;
  421. $this->metadataDirective = $input['MetadataDirective'] ?? null;
  422. $this->taggingDirective = $input['TaggingDirective'] ?? null;
  423. $this->serverSideEncryption = $input['ServerSideEncryption'] ?? null;
  424. $this->storageClass = $input['StorageClass'] ?? null;
  425. $this->websiteRedirectLocation = $input['WebsiteRedirectLocation'] ?? null;
  426. $this->sseCustomerAlgorithm = $input['SSECustomerAlgorithm'] ?? null;
  427. $this->sseCustomerKey = $input['SSECustomerKey'] ?? null;
  428. $this->sseCustomerKeyMd5 = $input['SSECustomerKeyMD5'] ?? null;
  429. $this->sseKmsKeyId = $input['SSEKMSKeyId'] ?? null;
  430. $this->sseKmsEncryptionContext = $input['SSEKMSEncryptionContext'] ?? null;
  431. $this->bucketKeyEnabled = $input['BucketKeyEnabled'] ?? null;
  432. $this->copySourceSseCustomerAlgorithm = $input['CopySourceSSECustomerAlgorithm'] ?? null;
  433. $this->copySourceSseCustomerKey = $input['CopySourceSSECustomerKey'] ?? null;
  434. $this->copySourceSseCustomerKeyMd5 = $input['CopySourceSSECustomerKeyMD5'] ?? null;
  435. $this->requestPayer = $input['RequestPayer'] ?? null;
  436. $this->tagging = $input['Tagging'] ?? null;
  437. $this->objectLockMode = $input['ObjectLockMode'] ?? null;
  438. $this->objectLockRetainUntilDate = !isset($input['ObjectLockRetainUntilDate']) ? null : ($input['ObjectLockRetainUntilDate'] instanceof \DateTimeImmutable ? $input['ObjectLockRetainUntilDate'] : new \DateTimeImmutable($input['ObjectLockRetainUntilDate']));
  439. $this->objectLockLegalHoldStatus = $input['ObjectLockLegalHoldStatus'] ?? null;
  440. $this->expectedBucketOwner = $input['ExpectedBucketOwner'] ?? null;
  441. $this->expectedSourceBucketOwner = $input['ExpectedSourceBucketOwner'] ?? null;
  442. parent::__construct($input);
  443. }
  444. public static function create($input): self
  445. {
  446. return $input instanceof self ? $input : new self($input);
  447. }
  448. /**
  449. * @return ObjectCannedACL::*|null
  450. */
  451. public function getAcl(): ?string
  452. {
  453. return $this->acl;
  454. }
  455. public function getBucket(): ?string
  456. {
  457. return $this->bucket;
  458. }
  459. public function getBucketKeyEnabled(): ?bool
  460. {
  461. return $this->bucketKeyEnabled;
  462. }
  463. public function getCacheControl(): ?string
  464. {
  465. return $this->cacheControl;
  466. }
  467. /**
  468. * @return ChecksumAlgorithm::*|null
  469. */
  470. public function getChecksumAlgorithm(): ?string
  471. {
  472. return $this->checksumAlgorithm;
  473. }
  474. public function getContentDisposition(): ?string
  475. {
  476. return $this->contentDisposition;
  477. }
  478. public function getContentEncoding(): ?string
  479. {
  480. return $this->contentEncoding;
  481. }
  482. public function getContentLanguage(): ?string
  483. {
  484. return $this->contentLanguage;
  485. }
  486. public function getContentType(): ?string
  487. {
  488. return $this->contentType;
  489. }
  490. public function getCopySource(): ?string
  491. {
  492. return $this->copySource;
  493. }
  494. public function getCopySourceIfMatch(): ?string
  495. {
  496. return $this->copySourceIfMatch;
  497. }
  498. public function getCopySourceIfModifiedSince(): ?\DateTimeImmutable
  499. {
  500. return $this->copySourceIfModifiedSince;
  501. }
  502. public function getCopySourceIfNoneMatch(): ?string
  503. {
  504. return $this->copySourceIfNoneMatch;
  505. }
  506. public function getCopySourceIfUnmodifiedSince(): ?\DateTimeImmutable
  507. {
  508. return $this->copySourceIfUnmodifiedSince;
  509. }
  510. public function getCopySourceSseCustomerAlgorithm(): ?string
  511. {
  512. return $this->copySourceSseCustomerAlgorithm;
  513. }
  514. public function getCopySourceSseCustomerKey(): ?string
  515. {
  516. return $this->copySourceSseCustomerKey;
  517. }
  518. public function getCopySourceSseCustomerKeyMd5(): ?string
  519. {
  520. return $this->copySourceSseCustomerKeyMd5;
  521. }
  522. public function getExpectedBucketOwner(): ?string
  523. {
  524. return $this->expectedBucketOwner;
  525. }
  526. public function getExpectedSourceBucketOwner(): ?string
  527. {
  528. return $this->expectedSourceBucketOwner;
  529. }
  530. public function getExpires(): ?\DateTimeImmutable
  531. {
  532. return $this->expires;
  533. }
  534. public function getGrantFullControl(): ?string
  535. {
  536. return $this->grantFullControl;
  537. }
  538. public function getGrantRead(): ?string
  539. {
  540. return $this->grantRead;
  541. }
  542. public function getGrantReadAcp(): ?string
  543. {
  544. return $this->grantReadAcp;
  545. }
  546. public function getGrantWriteAcp(): ?string
  547. {
  548. return $this->grantWriteAcp;
  549. }
  550. public function getKey(): ?string
  551. {
  552. return $this->key;
  553. }
  554. /**
  555. * @return array<string, string>
  556. */
  557. public function getMetadata(): array
  558. {
  559. return $this->metadata ?? [];
  560. }
  561. /**
  562. * @return MetadataDirective::*|null
  563. */
  564. public function getMetadataDirective(): ?string
  565. {
  566. return $this->metadataDirective;
  567. }
  568. /**
  569. * @return ObjectLockLegalHoldStatus::*|null
  570. */
  571. public function getObjectLockLegalHoldStatus(): ?string
  572. {
  573. return $this->objectLockLegalHoldStatus;
  574. }
  575. /**
  576. * @return ObjectLockMode::*|null
  577. */
  578. public function getObjectLockMode(): ?string
  579. {
  580. return $this->objectLockMode;
  581. }
  582. public function getObjectLockRetainUntilDate(): ?\DateTimeImmutable
  583. {
  584. return $this->objectLockRetainUntilDate;
  585. }
  586. /**
  587. * @return RequestPayer::*|null
  588. */
  589. public function getRequestPayer(): ?string
  590. {
  591. return $this->requestPayer;
  592. }
  593. /**
  594. * @return ServerSideEncryption::*|null
  595. */
  596. public function getServerSideEncryption(): ?string
  597. {
  598. return $this->serverSideEncryption;
  599. }
  600. public function getSseCustomerAlgorithm(): ?string
  601. {
  602. return $this->sseCustomerAlgorithm;
  603. }
  604. public function getSseCustomerKey(): ?string
  605. {
  606. return $this->sseCustomerKey;
  607. }
  608. public function getSseCustomerKeyMd5(): ?string
  609. {
  610. return $this->sseCustomerKeyMd5;
  611. }
  612. public function getSseKmsEncryptionContext(): ?string
  613. {
  614. return $this->sseKmsEncryptionContext;
  615. }
  616. public function getSseKmsKeyId(): ?string
  617. {
  618. return $this->sseKmsKeyId;
  619. }
  620. /**
  621. * @return StorageClass::*|null
  622. */
  623. public function getStorageClass(): ?string
  624. {
  625. return $this->storageClass;
  626. }
  627. public function getTagging(): ?string
  628. {
  629. return $this->tagging;
  630. }
  631. /**
  632. * @return TaggingDirective::*|null
  633. */
  634. public function getTaggingDirective(): ?string
  635. {
  636. return $this->taggingDirective;
  637. }
  638. public function getWebsiteRedirectLocation(): ?string
  639. {
  640. return $this->websiteRedirectLocation;
  641. }
  642. /**
  643. * @internal
  644. */
  645. public function request(): Request
  646. {
  647. // Prepare headers
  648. $headers = ['content-type' => 'application/xml'];
  649. if (null !== $this->acl) {
  650. if (!ObjectCannedACL::exists($this->acl)) {
  651. throw new InvalidArgument(sprintf('Invalid parameter "ACL" for "%s". The value "%s" is not a valid "ObjectCannedACL".', __CLASS__, $this->acl));
  652. }
  653. $headers['x-amz-acl'] = $this->acl;
  654. }
  655. if (null !== $this->cacheControl) {
  656. $headers['Cache-Control'] = $this->cacheControl;
  657. }
  658. if (null !== $this->checksumAlgorithm) {
  659. if (!ChecksumAlgorithm::exists($this->checksumAlgorithm)) {
  660. throw new InvalidArgument(sprintf('Invalid parameter "ChecksumAlgorithm" for "%s". The value "%s" is not a valid "ChecksumAlgorithm".', __CLASS__, $this->checksumAlgorithm));
  661. }
  662. $headers['x-amz-checksum-algorithm'] = $this->checksumAlgorithm;
  663. }
  664. if (null !== $this->contentDisposition) {
  665. $headers['Content-Disposition'] = $this->contentDisposition;
  666. }
  667. if (null !== $this->contentEncoding) {
  668. $headers['Content-Encoding'] = $this->contentEncoding;
  669. }
  670. if (null !== $this->contentLanguage) {
  671. $headers['Content-Language'] = $this->contentLanguage;
  672. }
  673. if (null !== $this->contentType) {
  674. $headers['Content-Type'] = $this->contentType;
  675. }
  676. if (null === $v = $this->copySource) {
  677. throw new InvalidArgument(sprintf('Missing parameter "CopySource" for "%s". The value cannot be null.', __CLASS__));
  678. }
  679. $headers['x-amz-copy-source'] = $v;
  680. if (null !== $this->copySourceIfMatch) {
  681. $headers['x-amz-copy-source-if-match'] = $this->copySourceIfMatch;
  682. }
  683. if (null !== $this->copySourceIfModifiedSince) {
  684. $headers['x-amz-copy-source-if-modified-since'] = $this->copySourceIfModifiedSince->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
  685. }
  686. if (null !== $this->copySourceIfNoneMatch) {
  687. $headers['x-amz-copy-source-if-none-match'] = $this->copySourceIfNoneMatch;
  688. }
  689. if (null !== $this->copySourceIfUnmodifiedSince) {
  690. $headers['x-amz-copy-source-if-unmodified-since'] = $this->copySourceIfUnmodifiedSince->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
  691. }
  692. if (null !== $this->expires) {
  693. $headers['Expires'] = $this->expires->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
  694. }
  695. if (null !== $this->grantFullControl) {
  696. $headers['x-amz-grant-full-control'] = $this->grantFullControl;
  697. }
  698. if (null !== $this->grantRead) {
  699. $headers['x-amz-grant-read'] = $this->grantRead;
  700. }
  701. if (null !== $this->grantReadAcp) {
  702. $headers['x-amz-grant-read-acp'] = $this->grantReadAcp;
  703. }
  704. if (null !== $this->grantWriteAcp) {
  705. $headers['x-amz-grant-write-acp'] = $this->grantWriteAcp;
  706. }
  707. if (null !== $this->metadataDirective) {
  708. if (!MetadataDirective::exists($this->metadataDirective)) {
  709. throw new InvalidArgument(sprintf('Invalid parameter "MetadataDirective" for "%s". The value "%s" is not a valid "MetadataDirective".', __CLASS__, $this->metadataDirective));
  710. }
  711. $headers['x-amz-metadata-directive'] = $this->metadataDirective;
  712. }
  713. if (null !== $this->taggingDirective) {
  714. if (!TaggingDirective::exists($this->taggingDirective)) {
  715. throw new InvalidArgument(sprintf('Invalid parameter "TaggingDirective" for "%s". The value "%s" is not a valid "TaggingDirective".', __CLASS__, $this->taggingDirective));
  716. }
  717. $headers['x-amz-tagging-directive'] = $this->taggingDirective;
  718. }
  719. if (null !== $this->serverSideEncryption) {
  720. if (!ServerSideEncryption::exists($this->serverSideEncryption)) {
  721. throw new InvalidArgument(sprintf('Invalid parameter "ServerSideEncryption" for "%s". The value "%s" is not a valid "ServerSideEncryption".', __CLASS__, $this->serverSideEncryption));
  722. }
  723. $headers['x-amz-server-side-encryption'] = $this->serverSideEncryption;
  724. }
  725. if (null !== $this->storageClass) {
  726. if (!StorageClass::exists($this->storageClass)) {
  727. throw new InvalidArgument(sprintf('Invalid parameter "StorageClass" for "%s". The value "%s" is not a valid "StorageClass".', __CLASS__, $this->storageClass));
  728. }
  729. $headers['x-amz-storage-class'] = $this->storageClass;
  730. }
  731. if (null !== $this->websiteRedirectLocation) {
  732. $headers['x-amz-website-redirect-location'] = $this->websiteRedirectLocation;
  733. }
  734. if (null !== $this->sseCustomerAlgorithm) {
  735. $headers['x-amz-server-side-encryption-customer-algorithm'] = $this->sseCustomerAlgorithm;
  736. }
  737. if (null !== $this->sseCustomerKey) {
  738. $headers['x-amz-server-side-encryption-customer-key'] = $this->sseCustomerKey;
  739. }
  740. if (null !== $this->sseCustomerKeyMd5) {
  741. $headers['x-amz-server-side-encryption-customer-key-MD5'] = $this->sseCustomerKeyMd5;
  742. }
  743. if (null !== $this->sseKmsKeyId) {
  744. $headers['x-amz-server-side-encryption-aws-kms-key-id'] = $this->sseKmsKeyId;
  745. }
  746. if (null !== $this->sseKmsEncryptionContext) {
  747. $headers['x-amz-server-side-encryption-context'] = $this->sseKmsEncryptionContext;
  748. }
  749. if (null !== $this->bucketKeyEnabled) {
  750. $headers['x-amz-server-side-encryption-bucket-key-enabled'] = $this->bucketKeyEnabled ? 'true' : 'false';
  751. }
  752. if (null !== $this->copySourceSseCustomerAlgorithm) {
  753. $headers['x-amz-copy-source-server-side-encryption-customer-algorithm'] = $this->copySourceSseCustomerAlgorithm;
  754. }
  755. if (null !== $this->copySourceSseCustomerKey) {
  756. $headers['x-amz-copy-source-server-side-encryption-customer-key'] = $this->copySourceSseCustomerKey;
  757. }
  758. if (null !== $this->copySourceSseCustomerKeyMd5) {
  759. $headers['x-amz-copy-source-server-side-encryption-customer-key-MD5'] = $this->copySourceSseCustomerKeyMd5;
  760. }
  761. if (null !== $this->requestPayer) {
  762. if (!RequestPayer::exists($this->requestPayer)) {
  763. throw new InvalidArgument(sprintf('Invalid parameter "RequestPayer" for "%s". The value "%s" is not a valid "RequestPayer".', __CLASS__, $this->requestPayer));
  764. }
  765. $headers['x-amz-request-payer'] = $this->requestPayer;
  766. }
  767. if (null !== $this->tagging) {
  768. $headers['x-amz-tagging'] = $this->tagging;
  769. }
  770. if (null !== $this->objectLockMode) {
  771. if (!ObjectLockMode::exists($this->objectLockMode)) {
  772. throw new InvalidArgument(sprintf('Invalid parameter "ObjectLockMode" for "%s". The value "%s" is not a valid "ObjectLockMode".', __CLASS__, $this->objectLockMode));
  773. }
  774. $headers['x-amz-object-lock-mode'] = $this->objectLockMode;
  775. }
  776. if (null !== $this->objectLockRetainUntilDate) {
  777. $headers['x-amz-object-lock-retain-until-date'] = $this->objectLockRetainUntilDate->format(\DateTimeInterface::ISO8601);
  778. }
  779. if (null !== $this->objectLockLegalHoldStatus) {
  780. if (!ObjectLockLegalHoldStatus::exists($this->objectLockLegalHoldStatus)) {
  781. throw new InvalidArgument(sprintf('Invalid parameter "ObjectLockLegalHoldStatus" for "%s". The value "%s" is not a valid "ObjectLockLegalHoldStatus".', __CLASS__, $this->objectLockLegalHoldStatus));
  782. }
  783. $headers['x-amz-object-lock-legal-hold'] = $this->objectLockLegalHoldStatus;
  784. }
  785. if (null !== $this->expectedBucketOwner) {
  786. $headers['x-amz-expected-bucket-owner'] = $this->expectedBucketOwner;
  787. }
  788. if (null !== $this->expectedSourceBucketOwner) {
  789. $headers['x-amz-source-expected-bucket-owner'] = $this->expectedSourceBucketOwner;
  790. }
  791. if (null !== $this->metadata) {
  792. foreach ($this->metadata as $key => $value) {
  793. $headers["x-amz-meta-$key"] = $value;
  794. }
  795. }
  796. // Prepare query
  797. $query = [];
  798. // Prepare URI
  799. $uri = [];
  800. if (null === $v = $this->bucket) {
  801. throw new InvalidArgument(sprintf('Missing parameter "Bucket" for "%s". The value cannot be null.', __CLASS__));
  802. }
  803. $uri['Bucket'] = $v;
  804. if (null === $v = $this->key) {
  805. throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__));
  806. }
  807. $uri['Key'] = $v;
  808. $uriString = '/' . rawurlencode($uri['Bucket']) . '/' . str_replace('%2F', '/', rawurlencode($uri['Key']));
  809. // Prepare Body
  810. $body = '';
  811. // Return the Request
  812. return new Request('PUT', $uriString, $query, $headers, StreamFactory::create($body));
  813. }
  814. /**
  815. * @param ObjectCannedACL::*|null $value
  816. */
  817. public function setAcl(?string $value): self
  818. {
  819. $this->acl = $value;
  820. return $this;
  821. }
  822. public function setBucket(?string $value): self
  823. {
  824. $this->bucket = $value;
  825. return $this;
  826. }
  827. public function setBucketKeyEnabled(?bool $value): self
  828. {
  829. $this->bucketKeyEnabled = $value;
  830. return $this;
  831. }
  832. public function setCacheControl(?string $value): self
  833. {
  834. $this->cacheControl = $value;
  835. return $this;
  836. }
  837. /**
  838. * @param ChecksumAlgorithm::*|null $value
  839. */
  840. public function setChecksumAlgorithm(?string $value): self
  841. {
  842. $this->checksumAlgorithm = $value;
  843. return $this;
  844. }
  845. public function setContentDisposition(?string $value): self
  846. {
  847. $this->contentDisposition = $value;
  848. return $this;
  849. }
  850. public function setContentEncoding(?string $value): self
  851. {
  852. $this->contentEncoding = $value;
  853. return $this;
  854. }
  855. public function setContentLanguage(?string $value): self
  856. {
  857. $this->contentLanguage = $value;
  858. return $this;
  859. }
  860. public function setContentType(?string $value): self
  861. {
  862. $this->contentType = $value;
  863. return $this;
  864. }
  865. public function setCopySource(?string $value): self
  866. {
  867. $this->copySource = $value;
  868. return $this;
  869. }
  870. public function setCopySourceIfMatch(?string $value): self
  871. {
  872. $this->copySourceIfMatch = $value;
  873. return $this;
  874. }
  875. public function setCopySourceIfModifiedSince(?\DateTimeImmutable $value): self
  876. {
  877. $this->copySourceIfModifiedSince = $value;
  878. return $this;
  879. }
  880. public function setCopySourceIfNoneMatch(?string $value): self
  881. {
  882. $this->copySourceIfNoneMatch = $value;
  883. return $this;
  884. }
  885. public function setCopySourceIfUnmodifiedSince(?\DateTimeImmutable $value): self
  886. {
  887. $this->copySourceIfUnmodifiedSince = $value;
  888. return $this;
  889. }
  890. public function setCopySourceSseCustomerAlgorithm(?string $value): self
  891. {
  892. $this->copySourceSseCustomerAlgorithm = $value;
  893. return $this;
  894. }
  895. public function setCopySourceSseCustomerKey(?string $value): self
  896. {
  897. $this->copySourceSseCustomerKey = $value;
  898. return $this;
  899. }
  900. public function setCopySourceSseCustomerKeyMd5(?string $value): self
  901. {
  902. $this->copySourceSseCustomerKeyMd5 = $value;
  903. return $this;
  904. }
  905. public function setExpectedBucketOwner(?string $value): self
  906. {
  907. $this->expectedBucketOwner = $value;
  908. return $this;
  909. }
  910. public function setExpectedSourceBucketOwner(?string $value): self
  911. {
  912. $this->expectedSourceBucketOwner = $value;
  913. return $this;
  914. }
  915. public function setExpires(?\DateTimeImmutable $value): self
  916. {
  917. $this->expires = $value;
  918. return $this;
  919. }
  920. public function setGrantFullControl(?string $value): self
  921. {
  922. $this->grantFullControl = $value;
  923. return $this;
  924. }
  925. public function setGrantRead(?string $value): self
  926. {
  927. $this->grantRead = $value;
  928. return $this;
  929. }
  930. public function setGrantReadAcp(?string $value): self
  931. {
  932. $this->grantReadAcp = $value;
  933. return $this;
  934. }
  935. public function setGrantWriteAcp(?string $value): self
  936. {
  937. $this->grantWriteAcp = $value;
  938. return $this;
  939. }
  940. public function setKey(?string $value): self
  941. {
  942. $this->key = $value;
  943. return $this;
  944. }
  945. /**
  946. * @param array<string, string> $value
  947. */
  948. public function setMetadata(array $value): self
  949. {
  950. $this->metadata = $value;
  951. return $this;
  952. }
  953. /**
  954. * @param MetadataDirective::*|null $value
  955. */
  956. public function setMetadataDirective(?string $value): self
  957. {
  958. $this->metadataDirective = $value;
  959. return $this;
  960. }
  961. /**
  962. * @param ObjectLockLegalHoldStatus::*|null $value
  963. */
  964. public function setObjectLockLegalHoldStatus(?string $value): self
  965. {
  966. $this->objectLockLegalHoldStatus = $value;
  967. return $this;
  968. }
  969. /**
  970. * @param ObjectLockMode::*|null $value
  971. */
  972. public function setObjectLockMode(?string $value): self
  973. {
  974. $this->objectLockMode = $value;
  975. return $this;
  976. }
  977. public function setObjectLockRetainUntilDate(?\DateTimeImmutable $value): self
  978. {
  979. $this->objectLockRetainUntilDate = $value;
  980. return $this;
  981. }
  982. /**
  983. * @param RequestPayer::*|null $value
  984. */
  985. public function setRequestPayer(?string $value): self
  986. {
  987. $this->requestPayer = $value;
  988. return $this;
  989. }
  990. /**
  991. * @param ServerSideEncryption::*|null $value
  992. */
  993. public function setServerSideEncryption(?string $value): self
  994. {
  995. $this->serverSideEncryption = $value;
  996. return $this;
  997. }
  998. public function setSseCustomerAlgorithm(?string $value): self
  999. {
  1000. $this->sseCustomerAlgorithm = $value;
  1001. return $this;
  1002. }
  1003. public function setSseCustomerKey(?string $value): self
  1004. {
  1005. $this->sseCustomerKey = $value;
  1006. return $this;
  1007. }
  1008. public function setSseCustomerKeyMd5(?string $value): self
  1009. {
  1010. $this->sseCustomerKeyMd5 = $value;
  1011. return $this;
  1012. }
  1013. public function setSseKmsEncryptionContext(?string $value): self
  1014. {
  1015. $this->sseKmsEncryptionContext = $value;
  1016. return $this;
  1017. }
  1018. public function setSseKmsKeyId(?string $value): self
  1019. {
  1020. $this->sseKmsKeyId = $value;
  1021. return $this;
  1022. }
  1023. /**
  1024. * @param StorageClass::*|null $value
  1025. */
  1026. public function setStorageClass(?string $value): self
  1027. {
  1028. $this->storageClass = $value;
  1029. return $this;
  1030. }
  1031. public function setTagging(?string $value): self
  1032. {
  1033. $this->tagging = $value;
  1034. return $this;
  1035. }
  1036. /**
  1037. * @param TaggingDirective::*|null $value
  1038. */
  1039. public function setTaggingDirective(?string $value): self
  1040. {
  1041. $this->taggingDirective = $value;
  1042. return $this;
  1043. }
  1044. public function setWebsiteRedirectLocation(?string $value): self
  1045. {
  1046. $this->websiteRedirectLocation = $value;
  1047. return $this;
  1048. }
  1049. }