PutObjectRequest.php 36 KB

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