CreateMultipartUploadRequest.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  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\ObjectCannedACL;
  9. use AsyncAws\S3\Enum\ObjectLockLegalHoldStatus;
  10. use AsyncAws\S3\Enum\ObjectLockMode;
  11. use AsyncAws\S3\Enum\RequestPayer;
  12. use AsyncAws\S3\Enum\ServerSideEncryption;
  13. use AsyncAws\S3\Enum\StorageClass;
  14. final class CreateMultipartUploadRequest extends Input
  15. {
  16. /**
  17. * The canned ACL to apply to the object.
  18. *
  19. * This action is not supported by Amazon S3 on Outposts.
  20. *
  21. * @var ObjectCannedACL::*|null
  22. */
  23. private $acl;
  24. /**
  25. * The name of the bucket to which to initiate the upload.
  26. *
  27. * When using this action with an access point, you must direct requests to the access point hostname. The access point
  28. * hostname takes the form *AccessPointName*-*AccountId*.s3-accesspoint.*Region*.amazonaws.com. When using this action
  29. * with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket
  30. * name. For more information about access point ARNs, see Using access points [^1] in the *Amazon S3 User Guide*.
  31. *
  32. * When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3
  33. * on Outposts hostname takes the form `*AccessPointName*-*AccountId*.*outpostID*.s3-outposts.*Region*.amazonaws.com`.
  34. * When you use this action with S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts access
  35. * point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts
  36. * [^2] in the *Amazon S3 User Guide*.
  37. *
  38. * [^1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html
  39. * [^2]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html
  40. *
  41. * @required
  42. *
  43. * @var string|null
  44. */
  45. private $bucket;
  46. /**
  47. * Specifies caching behavior along the request/reply chain.
  48. *
  49. * @var string|null
  50. */
  51. private $cacheControl;
  52. /**
  53. * Specifies presentational information for the object.
  54. *
  55. * @var string|null
  56. */
  57. private $contentDisposition;
  58. /**
  59. * Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to
  60. * obtain the media-type referenced by the Content-Type header field.
  61. *
  62. * @var string|null
  63. */
  64. private $contentEncoding;
  65. /**
  66. * The language the content is in.
  67. *
  68. * @var string|null
  69. */
  70. private $contentLanguage;
  71. /**
  72. * A standard MIME type describing the format of the object data.
  73. *
  74. * @var string|null
  75. */
  76. private $contentType;
  77. /**
  78. * The date and time at which the object is no longer cacheable.
  79. *
  80. * @var \DateTimeImmutable|null
  81. */
  82. private $expires;
  83. /**
  84. * Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.
  85. *
  86. * This action is not supported by Amazon S3 on Outposts.
  87. *
  88. * @var string|null
  89. */
  90. private $grantFullControl;
  91. /**
  92. * Allows grantee to read the object data and its metadata.
  93. *
  94. * This action is not supported by Amazon S3 on Outposts.
  95. *
  96. * @var string|null
  97. */
  98. private $grantRead;
  99. /**
  100. * Allows grantee to read the object ACL.
  101. *
  102. * This action is not supported by Amazon S3 on Outposts.
  103. *
  104. * @var string|null
  105. */
  106. private $grantReadAcp;
  107. /**
  108. * Allows grantee to write the ACL for the applicable object.
  109. *
  110. * This action is not supported by Amazon S3 on Outposts.
  111. *
  112. * @var string|null
  113. */
  114. private $grantWriteAcp;
  115. /**
  116. * Object key for which the multipart upload is to be initiated.
  117. *
  118. * @required
  119. *
  120. * @var string|null
  121. */
  122. private $key;
  123. /**
  124. * A map of metadata to store with the object in S3.
  125. *
  126. * @var array<string, string>|null
  127. */
  128. private $metadata;
  129. /**
  130. * The server-side encryption algorithm used when storing this object in Amazon S3 (for example, `AES256`, `aws:kms`).
  131. *
  132. * @var ServerSideEncryption::*|null
  133. */
  134. private $serverSideEncryption;
  135. /**
  136. * By default, Amazon S3 uses the STANDARD Storage Class to store newly created objects. The STANDARD storage class
  137. * provides high durability and high availability. Depending on performance needs, you can specify a different Storage
  138. * Class. Amazon S3 on Outposts only uses the OUTPOSTS Storage Class. For more information, see Storage Classes [^1] in
  139. * the *Amazon S3 User Guide*.
  140. *
  141. * [^1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html
  142. *
  143. * @var StorageClass::*|null
  144. */
  145. private $storageClass;
  146. /**
  147. * If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or
  148. * to an external URL. Amazon S3 stores the value of this header in the object metadata.
  149. *
  150. * @var string|null
  151. */
  152. private $websiteRedirectLocation;
  153. /**
  154. * Specifies the algorithm to use to when encrypting the object (for example, AES256).
  155. *
  156. * @var string|null
  157. */
  158. private $sseCustomerAlgorithm;
  159. /**
  160. * Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data. This value is used to store
  161. * the object and then it is discarded; Amazon S3 does not store the encryption key. The key must be appropriate for use
  162. * with the algorithm specified in the `x-amz-server-side-encryption-customer-algorithm` header.
  163. *
  164. * @var string|null
  165. */
  166. private $sseCustomerKey;
  167. /**
  168. * Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a
  169. * message integrity check to ensure that the encryption key was transmitted without error.
  170. *
  171. * @var string|null
  172. */
  173. private $sseCustomerKeyMd5;
  174. /**
  175. * Specifies the ID of the symmetric encryption customer managed key to use for object encryption. All GET and PUT
  176. * requests for an object protected by KMS will fail if they're not made via SSL or using SigV4. For information about
  177. * configuring any of the officially supported Amazon Web Services SDKs and Amazon Web Services CLI, see Specifying the
  178. * Signature Version in Request Authentication [^1] in the *Amazon S3 User Guide*.
  179. *
  180. * [^1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
  181. *
  182. * @var string|null
  183. */
  184. private $sseKmsKeyId;
  185. /**
  186. * Specifies the Amazon Web Services KMS Encryption Context to use for object encryption. The value of this header is a
  187. * base64-encoded UTF-8 string holding JSON with the encryption context key-value pairs.
  188. *
  189. * @var string|null
  190. */
  191. private $sseKmsEncryptionContext;
  192. /**
  193. * Specifies whether Amazon S3 should use an S3 Bucket Key for object encryption with server-side encryption using Key
  194. * Management Service (KMS) keys (SSE-KMS). Setting this header to `true` causes Amazon S3 to use an S3 Bucket Key for
  195. * object encryption with SSE-KMS.
  196. *
  197. * Specifying this header with an object action doesn’t affect bucket-level settings for S3 Bucket Key.
  198. *
  199. * @var bool|null
  200. */
  201. private $bucketKeyEnabled;
  202. /**
  203. * @var RequestPayer::*|null
  204. */
  205. private $requestPayer;
  206. /**
  207. * The tag-set for the object. The tag-set must be encoded as URL Query parameters.
  208. *
  209. * @var string|null
  210. */
  211. private $tagging;
  212. /**
  213. * Specifies the Object Lock mode that you want to apply to the uploaded object.
  214. *
  215. * @var ObjectLockMode::*|null
  216. */
  217. private $objectLockMode;
  218. /**
  219. * Specifies the date and time when you want the Object Lock to expire.
  220. *
  221. * @var \DateTimeImmutable|null
  222. */
  223. private $objectLockRetainUntilDate;
  224. /**
  225. * Specifies whether you want to apply a legal hold to the uploaded object.
  226. *
  227. * @var ObjectLockLegalHoldStatus::*|null
  228. */
  229. private $objectLockLegalHoldStatus;
  230. /**
  231. * The account ID of the expected bucket owner. If the bucket is owned by a different account, the request fails with
  232. * the HTTP status code `403 Forbidden` (access denied).
  233. *
  234. * @var string|null
  235. */
  236. private $expectedBucketOwner;
  237. /**
  238. * Indicates the algorithm you want Amazon S3 to use to create the checksum for the object. For more information, see
  239. * Checking object integrity [^1] in the *Amazon S3 User Guide*.
  240. *
  241. * [^1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html
  242. *
  243. * @var ChecksumAlgorithm::*|null
  244. */
  245. private $checksumAlgorithm;
  246. /**
  247. * @param array{
  248. * ACL?: ObjectCannedACL::*,
  249. * Bucket?: string,
  250. * CacheControl?: string,
  251. * ContentDisposition?: string,
  252. * ContentEncoding?: string,
  253. * ContentLanguage?: string,
  254. * ContentType?: string,
  255. * Expires?: \DateTimeImmutable|string,
  256. * GrantFullControl?: string,
  257. * GrantRead?: string,
  258. * GrantReadACP?: string,
  259. * GrantWriteACP?: string,
  260. * Key?: string,
  261. * Metadata?: array<string, string>,
  262. * ServerSideEncryption?: ServerSideEncryption::*,
  263. * StorageClass?: StorageClass::*,
  264. * WebsiteRedirectLocation?: string,
  265. * SSECustomerAlgorithm?: string,
  266. * SSECustomerKey?: string,
  267. * SSECustomerKeyMD5?: string,
  268. * SSEKMSKeyId?: string,
  269. * SSEKMSEncryptionContext?: string,
  270. * BucketKeyEnabled?: bool,
  271. * RequestPayer?: RequestPayer::*,
  272. * Tagging?: string,
  273. * ObjectLockMode?: ObjectLockMode::*,
  274. * ObjectLockRetainUntilDate?: \DateTimeImmutable|string,
  275. * ObjectLockLegalHoldStatus?: ObjectLockLegalHoldStatus::*,
  276. * ExpectedBucketOwner?: string,
  277. * ChecksumAlgorithm?: ChecksumAlgorithm::*,
  278. *
  279. * @region?: string,
  280. * } $input
  281. */
  282. public function __construct(array $input = [])
  283. {
  284. $this->acl = $input['ACL'] ?? null;
  285. $this->bucket = $input['Bucket'] ?? null;
  286. $this->cacheControl = $input['CacheControl'] ?? null;
  287. $this->contentDisposition = $input['ContentDisposition'] ?? null;
  288. $this->contentEncoding = $input['ContentEncoding'] ?? null;
  289. $this->contentLanguage = $input['ContentLanguage'] ?? null;
  290. $this->contentType = $input['ContentType'] ?? null;
  291. $this->expires = !isset($input['Expires']) ? null : ($input['Expires'] instanceof \DateTimeImmutable ? $input['Expires'] : new \DateTimeImmutable($input['Expires']));
  292. $this->grantFullControl = $input['GrantFullControl'] ?? null;
  293. $this->grantRead = $input['GrantRead'] ?? null;
  294. $this->grantReadAcp = $input['GrantReadACP'] ?? null;
  295. $this->grantWriteAcp = $input['GrantWriteACP'] ?? null;
  296. $this->key = $input['Key'] ?? null;
  297. $this->metadata = $input['Metadata'] ?? null;
  298. $this->serverSideEncryption = $input['ServerSideEncryption'] ?? null;
  299. $this->storageClass = $input['StorageClass'] ?? null;
  300. $this->websiteRedirectLocation = $input['WebsiteRedirectLocation'] ?? null;
  301. $this->sseCustomerAlgorithm = $input['SSECustomerAlgorithm'] ?? null;
  302. $this->sseCustomerKey = $input['SSECustomerKey'] ?? null;
  303. $this->sseCustomerKeyMd5 = $input['SSECustomerKeyMD5'] ?? null;
  304. $this->sseKmsKeyId = $input['SSEKMSKeyId'] ?? null;
  305. $this->sseKmsEncryptionContext = $input['SSEKMSEncryptionContext'] ?? null;
  306. $this->bucketKeyEnabled = $input['BucketKeyEnabled'] ?? null;
  307. $this->requestPayer = $input['RequestPayer'] ?? null;
  308. $this->tagging = $input['Tagging'] ?? null;
  309. $this->objectLockMode = $input['ObjectLockMode'] ?? null;
  310. $this->objectLockRetainUntilDate = !isset($input['ObjectLockRetainUntilDate']) ? null : ($input['ObjectLockRetainUntilDate'] instanceof \DateTimeImmutable ? $input['ObjectLockRetainUntilDate'] : new \DateTimeImmutable($input['ObjectLockRetainUntilDate']));
  311. $this->objectLockLegalHoldStatus = $input['ObjectLockLegalHoldStatus'] ?? null;
  312. $this->expectedBucketOwner = $input['ExpectedBucketOwner'] ?? null;
  313. $this->checksumAlgorithm = $input['ChecksumAlgorithm'] ?? null;
  314. parent::__construct($input);
  315. }
  316. public static function create($input): self
  317. {
  318. return $input instanceof self ? $input : new self($input);
  319. }
  320. /**
  321. * @return ObjectCannedACL::*|null
  322. */
  323. public function getAcl(): ?string
  324. {
  325. return $this->acl;
  326. }
  327. public function getBucket(): ?string
  328. {
  329. return $this->bucket;
  330. }
  331. public function getBucketKeyEnabled(): ?bool
  332. {
  333. return $this->bucketKeyEnabled;
  334. }
  335. public function getCacheControl(): ?string
  336. {
  337. return $this->cacheControl;
  338. }
  339. /**
  340. * @return ChecksumAlgorithm::*|null
  341. */
  342. public function getChecksumAlgorithm(): ?string
  343. {
  344. return $this->checksumAlgorithm;
  345. }
  346. public function getContentDisposition(): ?string
  347. {
  348. return $this->contentDisposition;
  349. }
  350. public function getContentEncoding(): ?string
  351. {
  352. return $this->contentEncoding;
  353. }
  354. public function getContentLanguage(): ?string
  355. {
  356. return $this->contentLanguage;
  357. }
  358. public function getContentType(): ?string
  359. {
  360. return $this->contentType;
  361. }
  362. public function getExpectedBucketOwner(): ?string
  363. {
  364. return $this->expectedBucketOwner;
  365. }
  366. public function getExpires(): ?\DateTimeImmutable
  367. {
  368. return $this->expires;
  369. }
  370. public function getGrantFullControl(): ?string
  371. {
  372. return $this->grantFullControl;
  373. }
  374. public function getGrantRead(): ?string
  375. {
  376. return $this->grantRead;
  377. }
  378. public function getGrantReadAcp(): ?string
  379. {
  380. return $this->grantReadAcp;
  381. }
  382. public function getGrantWriteAcp(): ?string
  383. {
  384. return $this->grantWriteAcp;
  385. }
  386. public function getKey(): ?string
  387. {
  388. return $this->key;
  389. }
  390. /**
  391. * @return array<string, string>
  392. */
  393. public function getMetadata(): array
  394. {
  395. return $this->metadata ?? [];
  396. }
  397. /**
  398. * @return ObjectLockLegalHoldStatus::*|null
  399. */
  400. public function getObjectLockLegalHoldStatus(): ?string
  401. {
  402. return $this->objectLockLegalHoldStatus;
  403. }
  404. /**
  405. * @return ObjectLockMode::*|null
  406. */
  407. public function getObjectLockMode(): ?string
  408. {
  409. return $this->objectLockMode;
  410. }
  411. public function getObjectLockRetainUntilDate(): ?\DateTimeImmutable
  412. {
  413. return $this->objectLockRetainUntilDate;
  414. }
  415. /**
  416. * @return RequestPayer::*|null
  417. */
  418. public function getRequestPayer(): ?string
  419. {
  420. return $this->requestPayer;
  421. }
  422. /**
  423. * @return ServerSideEncryption::*|null
  424. */
  425. public function getServerSideEncryption(): ?string
  426. {
  427. return $this->serverSideEncryption;
  428. }
  429. public function getSseCustomerAlgorithm(): ?string
  430. {
  431. return $this->sseCustomerAlgorithm;
  432. }
  433. public function getSseCustomerKey(): ?string
  434. {
  435. return $this->sseCustomerKey;
  436. }
  437. public function getSseCustomerKeyMd5(): ?string
  438. {
  439. return $this->sseCustomerKeyMd5;
  440. }
  441. public function getSseKmsEncryptionContext(): ?string
  442. {
  443. return $this->sseKmsEncryptionContext;
  444. }
  445. public function getSseKmsKeyId(): ?string
  446. {
  447. return $this->sseKmsKeyId;
  448. }
  449. /**
  450. * @return StorageClass::*|null
  451. */
  452. public function getStorageClass(): ?string
  453. {
  454. return $this->storageClass;
  455. }
  456. public function getTagging(): ?string
  457. {
  458. return $this->tagging;
  459. }
  460. public function getWebsiteRedirectLocation(): ?string
  461. {
  462. return $this->websiteRedirectLocation;
  463. }
  464. /**
  465. * @internal
  466. */
  467. public function request(): Request
  468. {
  469. // Prepare headers
  470. $headers = ['content-type' => 'application/xml'];
  471. if (null !== $this->acl) {
  472. if (!ObjectCannedACL::exists($this->acl)) {
  473. throw new InvalidArgument(sprintf('Invalid parameter "ACL" for "%s". The value "%s" is not a valid "ObjectCannedACL".', __CLASS__, $this->acl));
  474. }
  475. $headers['x-amz-acl'] = $this->acl;
  476. }
  477. if (null !== $this->cacheControl) {
  478. $headers['Cache-Control'] = $this->cacheControl;
  479. }
  480. if (null !== $this->contentDisposition) {
  481. $headers['Content-Disposition'] = $this->contentDisposition;
  482. }
  483. if (null !== $this->contentEncoding) {
  484. $headers['Content-Encoding'] = $this->contentEncoding;
  485. }
  486. if (null !== $this->contentLanguage) {
  487. $headers['Content-Language'] = $this->contentLanguage;
  488. }
  489. if (null !== $this->contentType) {
  490. $headers['Content-Type'] = $this->contentType;
  491. }
  492. if (null !== $this->expires) {
  493. $headers['Expires'] = $this->expires->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
  494. }
  495. if (null !== $this->grantFullControl) {
  496. $headers['x-amz-grant-full-control'] = $this->grantFullControl;
  497. }
  498. if (null !== $this->grantRead) {
  499. $headers['x-amz-grant-read'] = $this->grantRead;
  500. }
  501. if (null !== $this->grantReadAcp) {
  502. $headers['x-amz-grant-read-acp'] = $this->grantReadAcp;
  503. }
  504. if (null !== $this->grantWriteAcp) {
  505. $headers['x-amz-grant-write-acp'] = $this->grantWriteAcp;
  506. }
  507. if (null !== $this->serverSideEncryption) {
  508. if (!ServerSideEncryption::exists($this->serverSideEncryption)) {
  509. throw new InvalidArgument(sprintf('Invalid parameter "ServerSideEncryption" for "%s". The value "%s" is not a valid "ServerSideEncryption".', __CLASS__, $this->serverSideEncryption));
  510. }
  511. $headers['x-amz-server-side-encryption'] = $this->serverSideEncryption;
  512. }
  513. if (null !== $this->storageClass) {
  514. if (!StorageClass::exists($this->storageClass)) {
  515. throw new InvalidArgument(sprintf('Invalid parameter "StorageClass" for "%s". The value "%s" is not a valid "StorageClass".', __CLASS__, $this->storageClass));
  516. }
  517. $headers['x-amz-storage-class'] = $this->storageClass;
  518. }
  519. if (null !== $this->websiteRedirectLocation) {
  520. $headers['x-amz-website-redirect-location'] = $this->websiteRedirectLocation;
  521. }
  522. if (null !== $this->sseCustomerAlgorithm) {
  523. $headers['x-amz-server-side-encryption-customer-algorithm'] = $this->sseCustomerAlgorithm;
  524. }
  525. if (null !== $this->sseCustomerKey) {
  526. $headers['x-amz-server-side-encryption-customer-key'] = $this->sseCustomerKey;
  527. }
  528. if (null !== $this->sseCustomerKeyMd5) {
  529. $headers['x-amz-server-side-encryption-customer-key-MD5'] = $this->sseCustomerKeyMd5;
  530. }
  531. if (null !== $this->sseKmsKeyId) {
  532. $headers['x-amz-server-side-encryption-aws-kms-key-id'] = $this->sseKmsKeyId;
  533. }
  534. if (null !== $this->sseKmsEncryptionContext) {
  535. $headers['x-amz-server-side-encryption-context'] = $this->sseKmsEncryptionContext;
  536. }
  537. if (null !== $this->bucketKeyEnabled) {
  538. $headers['x-amz-server-side-encryption-bucket-key-enabled'] = $this->bucketKeyEnabled ? 'true' : 'false';
  539. }
  540. if (null !== $this->requestPayer) {
  541. if (!RequestPayer::exists($this->requestPayer)) {
  542. throw new InvalidArgument(sprintf('Invalid parameter "RequestPayer" for "%s". The value "%s" is not a valid "RequestPayer".', __CLASS__, $this->requestPayer));
  543. }
  544. $headers['x-amz-request-payer'] = $this->requestPayer;
  545. }
  546. if (null !== $this->tagging) {
  547. $headers['x-amz-tagging'] = $this->tagging;
  548. }
  549. if (null !== $this->objectLockMode) {
  550. if (!ObjectLockMode::exists($this->objectLockMode)) {
  551. throw new InvalidArgument(sprintf('Invalid parameter "ObjectLockMode" for "%s". The value "%s" is not a valid "ObjectLockMode".', __CLASS__, $this->objectLockMode));
  552. }
  553. $headers['x-amz-object-lock-mode'] = $this->objectLockMode;
  554. }
  555. if (null !== $this->objectLockRetainUntilDate) {
  556. $headers['x-amz-object-lock-retain-until-date'] = $this->objectLockRetainUntilDate->format(\DateTimeInterface::ISO8601);
  557. }
  558. if (null !== $this->objectLockLegalHoldStatus) {
  559. if (!ObjectLockLegalHoldStatus::exists($this->objectLockLegalHoldStatus)) {
  560. throw new InvalidArgument(sprintf('Invalid parameter "ObjectLockLegalHoldStatus" for "%s". The value "%s" is not a valid "ObjectLockLegalHoldStatus".', __CLASS__, $this->objectLockLegalHoldStatus));
  561. }
  562. $headers['x-amz-object-lock-legal-hold'] = $this->objectLockLegalHoldStatus;
  563. }
  564. if (null !== $this->expectedBucketOwner) {
  565. $headers['x-amz-expected-bucket-owner'] = $this->expectedBucketOwner;
  566. }
  567. if (null !== $this->checksumAlgorithm) {
  568. if (!ChecksumAlgorithm::exists($this->checksumAlgorithm)) {
  569. throw new InvalidArgument(sprintf('Invalid parameter "ChecksumAlgorithm" for "%s". The value "%s" is not a valid "ChecksumAlgorithm".', __CLASS__, $this->checksumAlgorithm));
  570. }
  571. $headers['x-amz-checksum-algorithm'] = $this->checksumAlgorithm;
  572. }
  573. if (null !== $this->metadata) {
  574. foreach ($this->metadata as $key => $value) {
  575. $headers["x-amz-meta-$key"] = $value;
  576. }
  577. }
  578. // Prepare query
  579. $query = [];
  580. // Prepare URI
  581. $uri = [];
  582. if (null === $v = $this->bucket) {
  583. throw new InvalidArgument(sprintf('Missing parameter "Bucket" for "%s". The value cannot be null.', __CLASS__));
  584. }
  585. $uri['Bucket'] = $v;
  586. if (null === $v = $this->key) {
  587. throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__));
  588. }
  589. $uri['Key'] = $v;
  590. $uriString = '/' . rawurlencode($uri['Bucket']) . '/' . str_replace('%2F', '/', rawurlencode($uri['Key'])) . '?uploads';
  591. // Prepare Body
  592. $body = '';
  593. // Return the Request
  594. return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body));
  595. }
  596. /**
  597. * @param ObjectCannedACL::*|null $value
  598. */
  599. public function setAcl(?string $value): self
  600. {
  601. $this->acl = $value;
  602. return $this;
  603. }
  604. public function setBucket(?string $value): self
  605. {
  606. $this->bucket = $value;
  607. return $this;
  608. }
  609. public function setBucketKeyEnabled(?bool $value): self
  610. {
  611. $this->bucketKeyEnabled = $value;
  612. return $this;
  613. }
  614. public function setCacheControl(?string $value): self
  615. {
  616. $this->cacheControl = $value;
  617. return $this;
  618. }
  619. /**
  620. * @param ChecksumAlgorithm::*|null $value
  621. */
  622. public function setChecksumAlgorithm(?string $value): self
  623. {
  624. $this->checksumAlgorithm = $value;
  625. return $this;
  626. }
  627. public function setContentDisposition(?string $value): self
  628. {
  629. $this->contentDisposition = $value;
  630. return $this;
  631. }
  632. public function setContentEncoding(?string $value): self
  633. {
  634. $this->contentEncoding = $value;
  635. return $this;
  636. }
  637. public function setContentLanguage(?string $value): self
  638. {
  639. $this->contentLanguage = $value;
  640. return $this;
  641. }
  642. public function setContentType(?string $value): self
  643. {
  644. $this->contentType = $value;
  645. return $this;
  646. }
  647. public function setExpectedBucketOwner(?string $value): self
  648. {
  649. $this->expectedBucketOwner = $value;
  650. return $this;
  651. }
  652. public function setExpires(?\DateTimeImmutable $value): self
  653. {
  654. $this->expires = $value;
  655. return $this;
  656. }
  657. public function setGrantFullControl(?string $value): self
  658. {
  659. $this->grantFullControl = $value;
  660. return $this;
  661. }
  662. public function setGrantRead(?string $value): self
  663. {
  664. $this->grantRead = $value;
  665. return $this;
  666. }
  667. public function setGrantReadAcp(?string $value): self
  668. {
  669. $this->grantReadAcp = $value;
  670. return $this;
  671. }
  672. public function setGrantWriteAcp(?string $value): self
  673. {
  674. $this->grantWriteAcp = $value;
  675. return $this;
  676. }
  677. public function setKey(?string $value): self
  678. {
  679. $this->key = $value;
  680. return $this;
  681. }
  682. /**
  683. * @param array<string, string> $value
  684. */
  685. public function setMetadata(array $value): self
  686. {
  687. $this->metadata = $value;
  688. return $this;
  689. }
  690. /**
  691. * @param ObjectLockLegalHoldStatus::*|null $value
  692. */
  693. public function setObjectLockLegalHoldStatus(?string $value): self
  694. {
  695. $this->objectLockLegalHoldStatus = $value;
  696. return $this;
  697. }
  698. /**
  699. * @param ObjectLockMode::*|null $value
  700. */
  701. public function setObjectLockMode(?string $value): self
  702. {
  703. $this->objectLockMode = $value;
  704. return $this;
  705. }
  706. public function setObjectLockRetainUntilDate(?\DateTimeImmutable $value): self
  707. {
  708. $this->objectLockRetainUntilDate = $value;
  709. return $this;
  710. }
  711. /**
  712. * @param RequestPayer::*|null $value
  713. */
  714. public function setRequestPayer(?string $value): self
  715. {
  716. $this->requestPayer = $value;
  717. return $this;
  718. }
  719. /**
  720. * @param ServerSideEncryption::*|null $value
  721. */
  722. public function setServerSideEncryption(?string $value): self
  723. {
  724. $this->serverSideEncryption = $value;
  725. return $this;
  726. }
  727. public function setSseCustomerAlgorithm(?string $value): self
  728. {
  729. $this->sseCustomerAlgorithm = $value;
  730. return $this;
  731. }
  732. public function setSseCustomerKey(?string $value): self
  733. {
  734. $this->sseCustomerKey = $value;
  735. return $this;
  736. }
  737. public function setSseCustomerKeyMd5(?string $value): self
  738. {
  739. $this->sseCustomerKeyMd5 = $value;
  740. return $this;
  741. }
  742. public function setSseKmsEncryptionContext(?string $value): self
  743. {
  744. $this->sseKmsEncryptionContext = $value;
  745. return $this;
  746. }
  747. public function setSseKmsKeyId(?string $value): self
  748. {
  749. $this->sseKmsKeyId = $value;
  750. return $this;
  751. }
  752. /**
  753. * @param StorageClass::*|null $value
  754. */
  755. public function setStorageClass(?string $value): self
  756. {
  757. $this->storageClass = $value;
  758. return $this;
  759. }
  760. public function setTagging(?string $value): self
  761. {
  762. $this->tagging = $value;
  763. return $this;
  764. }
  765. public function setWebsiteRedirectLocation(?string $value): self
  766. {
  767. $this->websiteRedirectLocation = $value;
  768. return $this;
  769. }
  770. }