PluginProbe ʕ •ᴥ•ʔ
Transferito: WP Migration / trunk
Transferito: WP Migration vtrunk
trunk 11.4.0 12.0.0 13.1.0 14.0.0 14.0.11 14.0.7 14.1.0 14.1.1 14.1.2 14.1.3 14.1.4
transferito / vendor / aws / aws-sdk-php / src / S3 / S3Client.php
transferito / vendor / aws / aws-sdk-php / src / S3 Last commit date
Crypto 11 months ago Exception 11 months ago RegionalEndpoint 11 months ago UseArnRegion 11 months ago AmbiguousSuccessParser.php 11 months ago ApplyChecksumMiddleware.php 11 months ago BatchDelete.php 11 months ago BucketEndpointArnMiddleware.php 11 months ago BucketEndpointMiddleware.php 11 months ago CalculatesChecksumTrait.php 11 months ago EndpointRegionHelperTrait.php 11 months ago GetBucketLocationParser.php 11 months ago MultipartCopy.php 11 months ago MultipartUploader.php 11 months ago MultipartUploadingTrait.php 11 months ago ObjectCopier.php 11 months ago ObjectUploader.php 11 months ago PermanentRedirectMiddleware.php 11 months ago PostObject.php 11 months ago PostObjectV4.php 11 months ago PutObjectUrlMiddleware.php 11 months ago RetryableMalformedResponseParser.php 11 months ago S3Client.php 11 months ago S3ClientInterface.php 11 months ago S3ClientTrait.php 11 months ago S3EndpointMiddleware.php 11 months ago S3MultiRegionClient.php 11 months ago S3UriParser.php 11 months ago SSECMiddleware.php 11 months ago StreamWrapper.php 11 months ago Transfer.php 11 months ago ValidateResponseChecksumParser.php 11 months ago
S3Client.php
1112 lines
1 <?php
2 namespace Aws\S3;
3
4 use Aws\Api\ApiProvider;
5 use Aws\Api\DocModel;
6 use Aws\Api\Service;
7 use Aws\AwsClient;
8 use Aws\CacheInterface;
9 use Aws\ClientResolver;
10 use Aws\Command;
11 use Aws\CommandInterface;
12 use Aws\Configuration\ConfigurationResolver;
13 use Aws\Exception\AwsException;
14 use Aws\HandlerList;
15 use Aws\Identity\S3\S3ExpressIdentityProvider;
16 use Aws\InputValidationMiddleware;
17 use Aws\Middleware;
18 use Aws\ResultInterface;
19 use Aws\Retry\QuotaManager;
20 use Aws\RetryMiddleware;
21 use Aws\RetryMiddlewareV2;
22 use Aws\S3\RegionalEndpoint\ConfigurationProvider;
23 use Aws\S3\UseArnRegion\Configuration;
24 use Aws\S3\UseArnRegion\ConfigurationInterface;
25 use Aws\S3\UseArnRegion\ConfigurationProvider as UseArnRegionConfigurationProvider;
26 use GuzzleHttp\Exception\RequestException;
27 use GuzzleHttp\Promise\PromiseInterface;
28 use Psr\Http\Message\RequestInterface;
29
30 /**
31 * Client used to interact with **Amazon Simple Storage Service (Amazon S3)**.
32 *
33 * @method \Aws\Result abortMultipartUpload(array $args = [])
34 * @method \GuzzleHttp\Promise\Promise abortMultipartUploadAsync(array $args = [])
35 * @method \Aws\Result completeMultipartUpload(array $args = [])
36 * @method \GuzzleHttp\Promise\Promise completeMultipartUploadAsync(array $args = [])
37 * @method \Aws\Result copyObject(array $args = [])
38 * @method \GuzzleHttp\Promise\Promise copyObjectAsync(array $args = [])
39 * @method \Aws\Result createBucket(array $args = [])
40 * @method \GuzzleHttp\Promise\Promise createBucketAsync(array $args = [])
41 * @method \Aws\Result createMultipartUpload(array $args = [])
42 * @method \GuzzleHttp\Promise\Promise createMultipartUploadAsync(array $args = [])
43 * @method \Aws\Result createSession(array $args = [])
44 * @method \GuzzleHttp\Promise\Promise createSessionAsync(array $args = [])
45 * @method \Aws\Result deleteBucket(array $args = [])
46 * @method \GuzzleHttp\Promise\Promise deleteBucketAsync(array $args = [])
47 * @method \Aws\Result deleteBucketAnalyticsConfiguration(array $args = [])
48 * @method \GuzzleHttp\Promise\Promise deleteBucketAnalyticsConfigurationAsync(array $args = [])
49 * @method \Aws\Result deleteBucketCors(array $args = [])
50 * @method \GuzzleHttp\Promise\Promise deleteBucketCorsAsync(array $args = [])
51 * @method \Aws\Result deleteBucketEncryption(array $args = [])
52 * @method \GuzzleHttp\Promise\Promise deleteBucketEncryptionAsync(array $args = [])
53 * @method \Aws\Result deleteBucketIntelligentTieringConfiguration(array $args = [])
54 * @method \GuzzleHttp\Promise\Promise deleteBucketIntelligentTieringConfigurationAsync(array $args = [])
55 * @method \Aws\Result deleteBucketInventoryConfiguration(array $args = [])
56 * @method \GuzzleHttp\Promise\Promise deleteBucketInventoryConfigurationAsync(array $args = [])
57 * @method \Aws\Result deleteBucketLifecycle(array $args = [])
58 * @method \GuzzleHttp\Promise\Promise deleteBucketLifecycleAsync(array $args = [])
59 * @method \Aws\Result deleteBucketMetricsConfiguration(array $args = [])
60 * @method \GuzzleHttp\Promise\Promise deleteBucketMetricsConfigurationAsync(array $args = [])
61 * @method \Aws\Result deleteBucketOwnershipControls(array $args = [])
62 * @method \GuzzleHttp\Promise\Promise deleteBucketOwnershipControlsAsync(array $args = [])
63 * @method \Aws\Result deleteBucketPolicy(array $args = [])
64 * @method \GuzzleHttp\Promise\Promise deleteBucketPolicyAsync(array $args = [])
65 * @method \Aws\Result deleteBucketReplication(array $args = [])
66 * @method \GuzzleHttp\Promise\Promise deleteBucketReplicationAsync(array $args = [])
67 * @method \Aws\Result deleteBucketTagging(array $args = [])
68 * @method \GuzzleHttp\Promise\Promise deleteBucketTaggingAsync(array $args = [])
69 * @method \Aws\Result deleteBucketWebsite(array $args = [])
70 * @method \GuzzleHttp\Promise\Promise deleteBucketWebsiteAsync(array $args = [])
71 * @method \Aws\Result deleteObject(array $args = [])
72 * @method \GuzzleHttp\Promise\Promise deleteObjectAsync(array $args = [])
73 * @method \Aws\Result deleteObjectTagging(array $args = [])
74 * @method \GuzzleHttp\Promise\Promise deleteObjectTaggingAsync(array $args = [])
75 * @method \Aws\Result deleteObjects(array $args = [])
76 * @method \GuzzleHttp\Promise\Promise deleteObjectsAsync(array $args = [])
77 * @method \Aws\Result deletePublicAccessBlock(array $args = [])
78 * @method \GuzzleHttp\Promise\Promise deletePublicAccessBlockAsync(array $args = [])
79 * @method \Aws\Result getBucketAccelerateConfiguration(array $args = [])
80 * @method \GuzzleHttp\Promise\Promise getBucketAccelerateConfigurationAsync(array $args = [])
81 * @method \Aws\Result getBucketAcl(array $args = [])
82 * @method \GuzzleHttp\Promise\Promise getBucketAclAsync(array $args = [])
83 * @method \Aws\Result getBucketAnalyticsConfiguration(array $args = [])
84 * @method \GuzzleHttp\Promise\Promise getBucketAnalyticsConfigurationAsync(array $args = [])
85 * @method \Aws\Result getBucketCors(array $args = [])
86 * @method \GuzzleHttp\Promise\Promise getBucketCorsAsync(array $args = [])
87 * @method \Aws\Result getBucketEncryption(array $args = [])
88 * @method \GuzzleHttp\Promise\Promise getBucketEncryptionAsync(array $args = [])
89 * @method \Aws\Result getBucketIntelligentTieringConfiguration(array $args = [])
90 * @method \GuzzleHttp\Promise\Promise getBucketIntelligentTieringConfigurationAsync(array $args = [])
91 * @method \Aws\Result getBucketInventoryConfiguration(array $args = [])
92 * @method \GuzzleHttp\Promise\Promise getBucketInventoryConfigurationAsync(array $args = [])
93 * @method \Aws\Result getBucketLifecycle(array $args = [])
94 * @method \GuzzleHttp\Promise\Promise getBucketLifecycleAsync(array $args = [])
95 * @method \Aws\Result getBucketLifecycleConfiguration(array $args = [])
96 * @method \GuzzleHttp\Promise\Promise getBucketLifecycleConfigurationAsync(array $args = [])
97 * @method \Aws\Result getBucketLocation(array $args = [])
98 * @method \GuzzleHttp\Promise\Promise getBucketLocationAsync(array $args = [])
99 * @method \Aws\Result getBucketLogging(array $args = [])
100 * @method \GuzzleHttp\Promise\Promise getBucketLoggingAsync(array $args = [])
101 * @method \Aws\Result getBucketMetricsConfiguration(array $args = [])
102 * @method \GuzzleHttp\Promise\Promise getBucketMetricsConfigurationAsync(array $args = [])
103 * @method \Aws\Result getBucketNotification(array $args = [])
104 * @method \GuzzleHttp\Promise\Promise getBucketNotificationAsync(array $args = [])
105 * @method \Aws\Result getBucketNotificationConfiguration(array $args = [])
106 * @method \GuzzleHttp\Promise\Promise getBucketNotificationConfigurationAsync(array $args = [])
107 * @method \Aws\Result getBucketOwnershipControls(array $args = [])
108 * @method \GuzzleHttp\Promise\Promise getBucketOwnershipControlsAsync(array $args = [])
109 * @method \Aws\Result getBucketPolicy(array $args = [])
110 * @method \GuzzleHttp\Promise\Promise getBucketPolicyAsync(array $args = [])
111 * @method \Aws\Result getBucketPolicyStatus(array $args = [])
112 * @method \GuzzleHttp\Promise\Promise getBucketPolicyStatusAsync(array $args = [])
113 * @method \Aws\Result getBucketReplication(array $args = [])
114 * @method \GuzzleHttp\Promise\Promise getBucketReplicationAsync(array $args = [])
115 * @method \Aws\Result getBucketRequestPayment(array $args = [])
116 * @method \GuzzleHttp\Promise\Promise getBucketRequestPaymentAsync(array $args = [])
117 * @method \Aws\Result getBucketTagging(array $args = [])
118 * @method \GuzzleHttp\Promise\Promise getBucketTaggingAsync(array $args = [])
119 * @method \Aws\Result getBucketVersioning(array $args = [])
120 * @method \GuzzleHttp\Promise\Promise getBucketVersioningAsync(array $args = [])
121 * @method \Aws\Result getBucketWebsite(array $args = [])
122 * @method \GuzzleHttp\Promise\Promise getBucketWebsiteAsync(array $args = [])
123 * @method \Aws\Result getObject(array $args = [])
124 * @method \GuzzleHttp\Promise\Promise getObjectAsync(array $args = [])
125 * @method \Aws\Result getObjectAcl(array $args = [])
126 * @method \GuzzleHttp\Promise\Promise getObjectAclAsync(array $args = [])
127 * @method \Aws\Result getObjectAttributes(array $args = [])
128 * @method \GuzzleHttp\Promise\Promise getObjectAttributesAsync(array $args = [])
129 * @method \Aws\Result getObjectLegalHold(array $args = [])
130 * @method \GuzzleHttp\Promise\Promise getObjectLegalHoldAsync(array $args = [])
131 * @method \Aws\Result getObjectLockConfiguration(array $args = [])
132 * @method \GuzzleHttp\Promise\Promise getObjectLockConfigurationAsync(array $args = [])
133 * @method \Aws\Result getObjectRetention(array $args = [])
134 * @method \GuzzleHttp\Promise\Promise getObjectRetentionAsync(array $args = [])
135 * @method \Aws\Result getObjectTagging(array $args = [])
136 * @method \GuzzleHttp\Promise\Promise getObjectTaggingAsync(array $args = [])
137 * @method \Aws\Result getObjectTorrent(array $args = [])
138 * @method \GuzzleHttp\Promise\Promise getObjectTorrentAsync(array $args = [])
139 * @method \Aws\Result getPublicAccessBlock(array $args = [])
140 * @method \GuzzleHttp\Promise\Promise getPublicAccessBlockAsync(array $args = [])
141 * @method \Aws\Result headBucket(array $args = [])
142 * @method \GuzzleHttp\Promise\Promise headBucketAsync(array $args = [])
143 * @method \Aws\Result headObject(array $args = [])
144 * @method \GuzzleHttp\Promise\Promise headObjectAsync(array $args = [])
145 * @method \Aws\Result listBucketAnalyticsConfigurations(array $args = [])
146 * @method \GuzzleHttp\Promise\Promise listBucketAnalyticsConfigurationsAsync(array $args = [])
147 * @method \Aws\Result listBucketIntelligentTieringConfigurations(array $args = [])
148 * @method \GuzzleHttp\Promise\Promise listBucketIntelligentTieringConfigurationsAsync(array $args = [])
149 * @method \Aws\Result listBucketInventoryConfigurations(array $args = [])
150 * @method \GuzzleHttp\Promise\Promise listBucketInventoryConfigurationsAsync(array $args = [])
151 * @method \Aws\Result listBucketMetricsConfigurations(array $args = [])
152 * @method \GuzzleHttp\Promise\Promise listBucketMetricsConfigurationsAsync(array $args = [])
153 * @method \Aws\Result listBuckets(array $args = [])
154 * @method \GuzzleHttp\Promise\Promise listBucketsAsync(array $args = [])
155 * @method \Aws\Result listDirectoryBuckets(array $args = [])
156 * @method \GuzzleHttp\Promise\Promise listDirectoryBucketsAsync(array $args = [])
157 * @method \Aws\Result listMultipartUploads(array $args = [])
158 * @method \GuzzleHttp\Promise\Promise listMultipartUploadsAsync(array $args = [])
159 * @method \Aws\Result listObjectVersions(array $args = [])
160 * @method \GuzzleHttp\Promise\Promise listObjectVersionsAsync(array $args = [])
161 * @method \Aws\Result listObjects(array $args = [])
162 * @method \GuzzleHttp\Promise\Promise listObjectsAsync(array $args = [])
163 * @method \Aws\Result listObjectsV2(array $args = [])
164 * @method \GuzzleHttp\Promise\Promise listObjectsV2Async(array $args = [])
165 * @method \Aws\Result listParts(array $args = [])
166 * @method \GuzzleHttp\Promise\Promise listPartsAsync(array $args = [])
167 * @method \Aws\Result putBucketAccelerateConfiguration(array $args = [])
168 * @method \GuzzleHttp\Promise\Promise putBucketAccelerateConfigurationAsync(array $args = [])
169 * @method \Aws\Result putBucketAcl(array $args = [])
170 * @method \GuzzleHttp\Promise\Promise putBucketAclAsync(array $args = [])
171 * @method \Aws\Result putBucketAnalyticsConfiguration(array $args = [])
172 * @method \GuzzleHttp\Promise\Promise putBucketAnalyticsConfigurationAsync(array $args = [])
173 * @method \Aws\Result putBucketCors(array $args = [])
174 * @method \GuzzleHttp\Promise\Promise putBucketCorsAsync(array $args = [])
175 * @method \Aws\Result putBucketEncryption(array $args = [])
176 * @method \GuzzleHttp\Promise\Promise putBucketEncryptionAsync(array $args = [])
177 * @method \Aws\Result putBucketIntelligentTieringConfiguration(array $args = [])
178 * @method \GuzzleHttp\Promise\Promise putBucketIntelligentTieringConfigurationAsync(array $args = [])
179 * @method \Aws\Result putBucketInventoryConfiguration(array $args = [])
180 * @method \GuzzleHttp\Promise\Promise putBucketInventoryConfigurationAsync(array $args = [])
181 * @method \Aws\Result putBucketLifecycle(array $args = [])
182 * @method \GuzzleHttp\Promise\Promise putBucketLifecycleAsync(array $args = [])
183 * @method \Aws\Result putBucketLifecycleConfiguration(array $args = [])
184 * @method \GuzzleHttp\Promise\Promise putBucketLifecycleConfigurationAsync(array $args = [])
185 * @method \Aws\Result putBucketLogging(array $args = [])
186 * @method \GuzzleHttp\Promise\Promise putBucketLoggingAsync(array $args = [])
187 * @method \Aws\Result putBucketMetricsConfiguration(array $args = [])
188 * @method \GuzzleHttp\Promise\Promise putBucketMetricsConfigurationAsync(array $args = [])
189 * @method \Aws\Result putBucketNotification(array $args = [])
190 * @method \GuzzleHttp\Promise\Promise putBucketNotificationAsync(array $args = [])
191 * @method \Aws\Result putBucketNotificationConfiguration(array $args = [])
192 * @method \GuzzleHttp\Promise\Promise putBucketNotificationConfigurationAsync(array $args = [])
193 * @method \Aws\Result putBucketOwnershipControls(array $args = [])
194 * @method \GuzzleHttp\Promise\Promise putBucketOwnershipControlsAsync(array $args = [])
195 * @method \Aws\Result putBucketPolicy(array $args = [])
196 * @method \GuzzleHttp\Promise\Promise putBucketPolicyAsync(array $args = [])
197 * @method \Aws\Result putBucketReplication(array $args = [])
198 * @method \GuzzleHttp\Promise\Promise putBucketReplicationAsync(array $args = [])
199 * @method \Aws\Result putBucketRequestPayment(array $args = [])
200 * @method \GuzzleHttp\Promise\Promise putBucketRequestPaymentAsync(array $args = [])
201 * @method \Aws\Result putBucketTagging(array $args = [])
202 * @method \GuzzleHttp\Promise\Promise putBucketTaggingAsync(array $args = [])
203 * @method \Aws\Result putBucketVersioning(array $args = [])
204 * @method \GuzzleHttp\Promise\Promise putBucketVersioningAsync(array $args = [])
205 * @method \Aws\Result putBucketWebsite(array $args = [])
206 * @method \GuzzleHttp\Promise\Promise putBucketWebsiteAsync(array $args = [])
207 * @method \Aws\Result putObject(array $args = [])
208 * @method \GuzzleHttp\Promise\Promise putObjectAsync(array $args = [])
209 * @method \Aws\Result putObjectAcl(array $args = [])
210 * @method \GuzzleHttp\Promise\Promise putObjectAclAsync(array $args = [])
211 * @method \Aws\Result putObjectLegalHold(array $args = [])
212 * @method \GuzzleHttp\Promise\Promise putObjectLegalHoldAsync(array $args = [])
213 * @method \Aws\Result putObjectLockConfiguration(array $args = [])
214 * @method \GuzzleHttp\Promise\Promise putObjectLockConfigurationAsync(array $args = [])
215 * @method \Aws\Result putObjectRetention(array $args = [])
216 * @method \GuzzleHttp\Promise\Promise putObjectRetentionAsync(array $args = [])
217 * @method \Aws\Result putObjectTagging(array $args = [])
218 * @method \GuzzleHttp\Promise\Promise putObjectTaggingAsync(array $args = [])
219 * @method \Aws\Result putPublicAccessBlock(array $args = [])
220 * @method \GuzzleHttp\Promise\Promise putPublicAccessBlockAsync(array $args = [])
221 * @method \Aws\Result restoreObject(array $args = [])
222 * @method \GuzzleHttp\Promise\Promise restoreObjectAsync(array $args = [])
223 * @method \Aws\Result selectObjectContent(array $args = [])
224 * @method \GuzzleHttp\Promise\Promise selectObjectContentAsync(array $args = [])
225 * @method \Aws\Result uploadPart(array $args = [])
226 * @method \GuzzleHttp\Promise\Promise uploadPartAsync(array $args = [])
227 * @method \Aws\Result uploadPartCopy(array $args = [])
228 * @method \GuzzleHttp\Promise\Promise uploadPartCopyAsync(array $args = [])
229 * @method \Aws\Result writeGetObjectResponse(array $args = [])
230 * @method \GuzzleHttp\Promise\Promise writeGetObjectResponseAsync(array $args = [])
231 */
232 class S3Client extends AwsClient implements S3ClientInterface
233 {
234 use S3ClientTrait;
235
236 /** @var array */
237 private static $mandatoryAttributes = ['Bucket', 'Key'];
238
239 public static function getArguments()
240 {
241 $args = parent::getArguments();
242 $args['retries']['fn'] = [__CLASS__, '_applyRetryConfig'];
243 $args['api_provider']['fn'] = [__CLASS__, '_applyApiProvider'];
244
245 return $args + [
246 'bucket_endpoint' => [
247 'type' => 'config',
248 'valid' => ['bool'],
249 'doc' => 'Set to true to send requests to a hardcoded '
250 . 'bucket endpoint rather than create an endpoint as a '
251 . 'result of injecting the bucket into the URL. This '
252 . 'option is useful for interacting with CNAME endpoints.',
253 ],
254 'use_arn_region' => [
255 'type' => 'config',
256 'valid' => [
257 'bool',
258 Configuration::class,
259 CacheInterface::class,
260 'callable'
261 ],
262 'doc' => 'Set to true to allow passed in ARNs to override'
263 . ' client region. Accepts...',
264 'fn' => [__CLASS__, '_apply_use_arn_region'],
265 'default' => [UseArnRegionConfigurationProvider::class, 'defaultProvider'],
266 ],
267 'use_accelerate_endpoint' => [
268 'type' => 'config',
269 'valid' => ['bool'],
270 'doc' => 'Set to true to send requests to an S3 Accelerate'
271 . ' endpoint by default. Can be enabled or disabled on'
272 . ' individual operations by setting'
273 . ' \'@use_accelerate_endpoint\' to true or false. Note:'
274 . ' you must enable S3 Accelerate on a bucket before it can'
275 . ' be accessed via an Accelerate endpoint.',
276 'default' => false,
277 ],
278 'use_path_style_endpoint' => [
279 'type' => 'config',
280 'valid' => ['bool'],
281 'doc' => 'Set to true to send requests to an S3 path style'
282 . ' endpoint by default.'
283 . ' Can be enabled or disabled on individual operations by setting'
284 . ' \'@use_path_style_endpoint\' to true or false.',
285 'default' => false,
286 ],
287 'disable_multiregion_access_points' => [
288 'type' => 'config',
289 'valid' => ['bool'],
290 'doc' => 'Set to true to disable the usage of'
291 . ' multi region access points. These are enabled by default.'
292 . ' Can be enabled or disabled on individual operations by setting'
293 . ' \'@disable_multiregion_access_points\' to true or false.',
294 'default' => false,
295 ],
296 'disable_express_session_auth' => [
297 'type' => 'config',
298 'valid' => ['bool'],
299 'doc' => 'Set to true to disable the usage of'
300 . ' s3 express session authentication. This is enabled by default.',
301 'default' => [__CLASS__, '_default_disable_express_session_auth'],
302 ],
303 's3_express_identity_provider' => [
304 'type' => 'config',
305 'valid' => [
306 'bool',
307 'callable'
308 ],
309 'doc' => 'Specifies the provider used to generate identities to sign s3 express requests. '
310 . 'Set to `false` to disable s3 express auth, or a callable provider used to create s3 express '
311 . 'identities or return null.',
312 'default' => [__CLASS__, '_default_s3_express_identity_provider'],
313 ],
314 ];
315 }
316
317 /**
318 * {@inheritdoc}
319 *
320 * In addition to the options available to
321 * {@see Aws\AwsClient::__construct}, S3Client accepts the following
322 * options:
323 *
324 * - bucket_endpoint: (bool) Set to true to send requests to a
325 * hardcoded bucket endpoint rather than create an endpoint as a result
326 * of injecting the bucket into the URL. This option is useful for
327 * interacting with CNAME endpoints. Note: if you are using version 2.243.0
328 * and above and do not expect the bucket name to appear in the host, you will
329 * also need to set `use_path_style_endpoint` to `true`.
330 * - calculate_md5: (bool) Set to false to disable calculating an MD5
331 * for all Amazon S3 signed uploads.
332 * - s3_us_east_1_regional_endpoint:
333 * (Aws\S3\RegionalEndpoint\ConfigurationInterface|Aws\CacheInterface\|callable|string|array)
334 * Specifies whether to use regional or legacy endpoints for the us-east-1
335 * region. Provide an Aws\S3\RegionalEndpoint\ConfigurationInterface object, an
336 * instance of Aws\CacheInterface, a callable configuration provider used
337 * to create endpoint configuration, a string value of `legacy` or
338 * `regional`, or an associative array with the following keys:
339 * endpoint_types: (string) Set to `legacy` or `regional`, defaults to
340 * `legacy`
341 * - use_accelerate_endpoint: (bool) Set to true to send requests to an S3
342 * Accelerate endpoint by default. Can be enabled or disabled on
343 * individual operations by setting '@use_accelerate_endpoint' to true or
344 * false. Note: you must enable S3 Accelerate on a bucket before it can be
345 * accessed via an Accelerate endpoint.
346 * - use_arn_region: (Aws\S3\UseArnRegion\ConfigurationInterface,
347 * Aws\CacheInterface, bool, callable) Set to true to enable the client
348 * to use the region from a supplied ARN argument instead of the client's
349 * region. Provide an instance of Aws\S3\UseArnRegion\ConfigurationInterface,
350 * an instance of Aws\CacheInterface, a callable that provides a promise for
351 * a Configuration object, or a boolean value. Defaults to false (i.e.
352 * the SDK will not follow the ARN region if it conflicts with the client
353 * region and instead throw an error).
354 * - use_dual_stack_endpoint: (bool) Set to true to send requests to an S3
355 * Dual Stack endpoint by default, which enables IPv6 Protocol.
356 * Can be enabled or disabled on individual operations by setting
357 * '@use_dual_stack_endpoint\' to true or false. Note:
358 * you cannot use it together with an accelerate endpoint.
359 * - use_path_style_endpoint: (bool) Set to true to send requests to an S3
360 * path style endpoint by default.
361 * Can be enabled or disabled on individual operations by setting
362 * '@use_path_style_endpoint\' to true or false. Note:
363 * you cannot use it together with an accelerate endpoint.
364 * - disable_multiregion_access_points: (bool) Set to true to disable
365 * sending multi region requests. They are enabled by default.
366 * Can be enabled or disabled on individual operations by setting
367 * '@disable_multiregion_access_points\' to true or false. Note:
368 * you cannot use it together with an accelerate or dualstack endpoint.
369 *
370 * @param array $args
371 */
372 public function __construct(array $args)
373 {
374 if (
375 !isset($args['s3_us_east_1_regional_endpoint'])
376 || $args['s3_us_east_1_regional_endpoint'] instanceof CacheInterface
377 ) {
378 $args['s3_us_east_1_regional_endpoint'] = ConfigurationProvider::defaultProvider($args);
379 }
380 $this->addBuiltIns($args);
381 parent::__construct($args);
382 $stack = $this->getHandlerList();
383 $stack->appendInit(SSECMiddleware::wrap($this->getEndpoint()->getScheme()), 's3.ssec');
384 $stack->appendBuild(ApplyChecksumMiddleware::wrap($this->getApi()), 's3.checksum');
385 $stack->appendBuild(
386 Middleware::contentType(['PutObject', 'UploadPart']),
387 's3.content_type'
388 );
389
390 if ($this->getConfig('bucket_endpoint')) {
391 $stack->appendBuild(BucketEndpointMiddleware::wrap(), 's3.bucket_endpoint');
392 } elseif (!$this->isUseEndpointV2()) {
393 $stack->appendBuild(
394 S3EndpointMiddleware::wrap(
395 $this->getRegion(),
396 $this->getConfig('endpoint_provider'),
397 [
398 'accelerate' => $this->getConfig('use_accelerate_endpoint'),
399 'path_style' => $this->getConfig('use_path_style_endpoint'),
400 'use_fips_endpoint' => $this->getConfig('use_fips_endpoint'),
401 'dual_stack' =>
402 $this->getConfig('use_dual_stack_endpoint')->isUseDualStackEndpoint(),
403
404 ]
405 ),
406 's3.endpoint_middleware'
407 );
408 }
409
410 $stack->appendBuild(
411 BucketEndpointArnMiddleware::wrap(
412 $this->getApi(),
413 $this->getRegion(),
414 [
415 'use_arn_region' => $this->getConfig('use_arn_region'),
416 'accelerate' => $this->getConfig('use_accelerate_endpoint'),
417 'path_style' => $this->getConfig('use_path_style_endpoint'),
418 'dual_stack' =>
419 $this->getConfig('use_dual_stack_endpoint')->isUseDualStackEndpoint(),
420 'use_fips_endpoint' => $this->getConfig('use_fips_endpoint'),
421 'disable_multiregion_access_points' =>
422 $this->getConfig('disable_multiregion_access_points'),
423 'endpoint' => isset($args['endpoint'])
424 ? $args['endpoint']
425 : null
426 ],
427 $this->isUseEndpointV2()
428 ),
429 's3.bucket_endpoint_arn'
430 );
431 if ($this->getConfig('disable_express_session_auth')) {
432 $stack->prependSign(
433 $this->getDisableExpressSessionAuthMiddleware(),
434 's3.disable_express_session_auth'
435 );
436 }
437
438 $stack->appendValidate(
439 InputValidationMiddleware::wrap($this->getApi(), self::$mandatoryAttributes),
440 'input_validation_middleware'
441 );
442 $stack->appendSign(PutObjectUrlMiddleware::wrap(), 's3.put_object_url');
443 $stack->appendSign(PermanentRedirectMiddleware::wrap(), 's3.permanent_redirect');
444 $stack->appendInit(Middleware::sourceFile($this->getApi()), 's3.source_file');
445 $stack->appendInit($this->getSaveAsParameter(), 's3.save_as');
446 $stack->appendInit($this->getLocationConstraintMiddleware(), 's3.location');
447 $stack->appendInit($this->getEncodingTypeMiddleware(), 's3.auto_encode');
448 $stack->appendInit($this->getHeadObjectMiddleware(), 's3.head_object');
449 if ($this->isUseEndpointV2()) {
450 $this->processEndpointV2Model();
451 $stack->after('builder',
452 's3.check_empty_path_with_query',
453 $this->getEmptyPathWithQuery());
454 }
455 }
456
457 /**
458 * Determine if a string is a valid name for a DNS compatible Amazon S3
459 * bucket.
460 *
461 * DNS compatible bucket names can be used as a subdomain in a URL (e.g.,
462 * "<bucket>.s3.amazonaws.com").
463 *
464 * @param string $bucket Bucket name to check.
465 *
466 * @return bool
467 */
468 public static function isBucketDnsCompatible($bucket)
469 {
470 if (!is_string($bucket)) {
471 return false;
472 }
473 $bucketLen = strlen($bucket);
474
475 return ($bucketLen >= 3 && $bucketLen <= 63) &&
476 // Cannot look like an IP address
477 !filter_var($bucket, FILTER_VALIDATE_IP) &&
478 preg_match('/^[a-z0-9]([a-z0-9\-\.]*[a-z0-9])?$/', $bucket);
479 }
480
481 public static function _apply_use_arn_region($value, array &$args, HandlerList $list)
482 {
483 if ($value instanceof CacheInterface) {
484 $value = UseArnRegionConfigurationProvider::defaultProvider($args);
485 }
486 if (is_callable($value)) {
487 $value = $value();
488 }
489 if ($value instanceof PromiseInterface) {
490 $value = $value->wait();
491 }
492 if ($value instanceof ConfigurationInterface) {
493 $args['use_arn_region'] = $value;
494 } else {
495 // The Configuration class itself will validate other inputs
496 $args['use_arn_region'] = new Configuration($value);
497 }
498 }
499
500 public function createPresignedRequest(CommandInterface $command, $expires, array $options = [])
501 {
502 $command = clone $command;
503 $command->getHandlerList()->remove('signer');
504 $request = \Aws\serialize($command);
505 $signing_name = empty($command->getAuthSchemes())
506 ? $this->getSigningName($request->getUri()->getHost())
507 : $command->getAuthSchemes()['name'];
508 $signature_version = $this->getSignatureVersionFromCommand($command);
509
510 /** @var \Aws\Signature\SignatureInterface $signer */
511 $signer = call_user_func(
512 $this->getSignatureProvider(),
513 $signature_version,
514 $signing_name,
515 $this->getConfig('signing_region')
516 );
517 if ($signature_version == 'v4-s3express') {
518 $provider = $this->getConfig('s3_express_identity_provider');
519 $credentials = $provider($command)->wait();
520 } else {
521 $credentials = $this->getCredentials()->wait();
522 }
523 return $signer->presign(
524 $request,
525 $credentials,
526 $expires,
527 $options
528 );
529 }
530
531 /**
532 * Returns the URL to an object identified by its bucket and key.
533 *
534 * The URL returned by this method is not signed nor does it ensure that the
535 * bucket and key given to the method exist. If you need a signed URL, then
536 * use the {@see \Aws\S3\S3Client::createPresignedRequest} method and get
537 * the URI of the signed request.
538 *
539 * @param string $bucket The name of the bucket where the object is located
540 * @param string $key The key of the object
541 *
542 * @return string The URL to the object
543 */
544 public function getObjectUrl($bucket, $key)
545 {
546 $command = $this->getCommand('GetObject', [
547 'Bucket' => $bucket,
548 'Key' => $key
549 ]);
550
551 return (string) \Aws\serialize($command)->getUri();
552 }
553
554 /**
555 * Raw URL encode a key and allow for '/' characters
556 *
557 * @param string $key Key to encode
558 *
559 * @return string Returns the encoded key
560 */
561 public static function encodeKey($key)
562 {
563 return str_replace('%2F', '/', rawurlencode($key));
564 }
565
566 /**
567 * Provides a middleware that removes the need to specify LocationConstraint on CreateBucket.
568 *
569 * @return \Closure
570 */
571 private function getLocationConstraintMiddleware()
572 {
573 $region = $this->getRegion();
574 return static function (callable $handler) use ($region) {
575 return function (Command $command, $request = null) use ($handler, $region) {
576 if ($command->getName() === 'CreateBucket') {
577 $locationConstraint = isset($command['CreateBucketConfiguration']['LocationConstraint'])
578 ? $command['CreateBucketConfiguration']['LocationConstraint']
579 : null;
580
581 if ($locationConstraint === 'us-east-1') {
582 unset($command['CreateBucketConfiguration']);
583 } elseif ('us-east-1' !== $region && empty($locationConstraint)) {
584 $command['CreateBucketConfiguration'] = ['LocationConstraint' => $region];
585 }
586 }
587
588 return $handler($command, $request);
589 };
590 };
591 }
592
593 /**
594 * Provides a middleware that supports the `SaveAs` parameter.
595 *
596 * @return \Closure
597 */
598 private function getSaveAsParameter()
599 {
600 return static function (callable $handler) {
601 return function (Command $command, $request = null) use ($handler) {
602 if ($command->getName() === 'GetObject' && isset($command['SaveAs'])) {
603 $command['@http']['sink'] = $command['SaveAs'];
604 unset($command['SaveAs']);
605 }
606
607 return $handler($command, $request);
608 };
609 };
610 }
611
612 /**
613 * Provides a middleware that disables content decoding on HeadObject
614 * commands.
615 *
616 * @return \Closure
617 */
618 private function getHeadObjectMiddleware()
619 {
620 return static function (callable $handler) {
621 return function (
622 CommandInterface $command,
623 RequestInterface $request = null
624 ) use ($handler) {
625 if ($command->getName() === 'HeadObject'
626 && !isset($command['@http']['decode_content'])
627 ) {
628 $command['@http']['decode_content'] = false;
629 }
630
631 return $handler($command, $request);
632 };
633 };
634 }
635
636 /**
637 * Provides a middleware that autopopulates the EncodingType parameter on
638 * ListObjects commands.
639 *
640 * @return \Closure
641 */
642 private function getEncodingTypeMiddleware()
643 {
644 return static function (callable $handler) {
645 return function (Command $command, $request = null) use ($handler) {
646 $autoSet = false;
647 if ($command->getName() === 'ListObjects'
648 && empty($command['EncodingType'])
649 ) {
650 $command['EncodingType'] = 'url';
651 $autoSet = true;
652 }
653
654 return $handler($command, $request)
655 ->then(function (ResultInterface $result) use ($autoSet) {
656 if ($result['EncodingType'] === 'url' && $autoSet) {
657 static $topLevel = [
658 'Delimiter',
659 'Marker',
660 'NextMarker',
661 'Prefix',
662 ];
663 static $nested = [
664 ['Contents', 'Key'],
665 ['CommonPrefixes', 'Prefix'],
666 ];
667
668 foreach ($topLevel as $key) {
669 if (isset($result[$key])) {
670 $result[$key] = urldecode($result[$key]);
671 }
672 }
673 foreach ($nested as $steps) {
674 if (isset($result[$steps[0]])) {
675 foreach ($result[$steps[0]] as $key => $part) {
676 if (isset($part[$steps[1]])) {
677 $result[$steps[0]][$key][$steps[1]]
678 = urldecode($part[$steps[1]]);
679 }
680 }
681 }
682 }
683
684 }
685
686 return $result;
687 });
688 };
689 };
690 }
691
692 /**
693 * Provides a middleware that checks for an empty path and a
694 * non-empty query string.
695 *
696 * @return \Closure
697 */
698 private function getEmptyPathWithQuery()
699 {
700 return static function (callable $handler) {
701 return function (Command $command, RequestInterface $request) use ($handler) {
702 $uri = $request->getUri();
703 if (empty($uri->getPath()) && !empty($uri->getQuery())) {
704 $uri = $uri->withPath('/');
705 $request = $request->withUri($uri);
706 }
707
708 return $handler($command, $request);
709 };
710 };
711 }
712
713 /**
714 * Provides a middleware that disables express session auth when
715 * customers opt out of it.
716 *
717 * @return \Closure
718 */
719 private function getDisableExpressSessionAuthMiddleware()
720 {
721 return function (callable $handler) {
722 return function (
723 CommandInterface $command,
724 RequestInterface $request = null
725 ) use ($handler) {
726 if (!empty($command->getAuthSchemes()['version'] )
727 && $command->getAuthSchemes()['version'] == 'v4-s3express'
728 ) {
729 $authScheme = $command->getAuthSchemes();
730 $authScheme['version'] = 's3v4';
731 $command->setAuthSchemes($authScheme);
732 }
733 return $handler($command, $request);
734 };
735 };
736 }
737
738 /**
739 * Special handling for when the service name is s3-object-lambda.
740 * So, if the host contains s3-object-lambda, then the service name
741 * returned is s3-object-lambda, otherwise the default signing service is returned.
742 * @param string $host The host to validate if is a s3-object-lambda URL.
743 * @return string returns the signing service name to be used
744 */
745 private function getSigningName($host)
746 {
747 if (strpos( $host, 's3-object-lambda')) {
748 return 's3-object-lambda';
749 }
750
751 return $this->getConfig('signing_name');
752 }
753
754 public static function _default_disable_express_session_auth(array &$args) {
755 return ConfigurationResolver::resolve(
756 's3_disable_express_session_auth',
757 false,
758 'bool',
759 $args
760 );
761 }
762
763 public static function _default_s3_express_identity_provider(array $args)
764 {
765 if ($args['config']['disable_express_session_auth']) {
766 return false;
767 }
768 return new S3ExpressIdentityProvider($args['region']);
769 }
770
771 /**
772 * Modifies API definition to remove `Bucket` from request URIs.
773 * This is now handled by the endpoint ruleset.
774 *
775 * @return void
776 *
777 * @internal
778 */
779 private function processEndpointV2Model()
780 {
781 $definition = $this->getApi()->getDefinition();
782
783 foreach($definition['operations'] as &$operation) {
784 if (isset($operation['http']['requestUri'])) {
785 $requestUri = $operation['http']['requestUri'];
786 if ($requestUri === "/{Bucket}") {
787 $requestUri = str_replace('/{Bucket}', '/', $requestUri);
788 } else {
789 $requestUri = str_replace('/{Bucket}', '', $requestUri);
790 }
791 $operation['http']['requestUri'] = $requestUri;
792 }
793 }
794 $this->getApi()->setDefinition($definition);
795 }
796
797 /**
798 * Adds service-specific client built-in values
799 *
800 * @return void
801 */
802 private function addBuiltIns($args)
803 {
804 if ($args['region'] !== 'us-east-1') {
805 return false;
806 }
807 $key = 'AWS::S3::UseGlobalEndpoint';
808 $result = $args['s3_us_east_1_regional_endpoint'] instanceof \Closure ?
809 $args['s3_us_east_1_regional_endpoint']()->wait() : $args['s3_us_east_1_regional_endpoint'];
810
811 if (is_string($result)) {
812 if ($result === 'regional') {
813 $value = false;
814 } else if ($result === 'legacy') {
815 $value = true;
816 } else {
817 return;
818 }
819 } else {
820 if ($result->isFallback()
821 || $result->getEndpointsType() === 'legacy'
822 ) {
823 $value = true;
824 } else {
825 $value = false;
826 }
827 }
828 $this->clientBuiltIns[$key] = $value;
829 }
830
831 /** @internal */
832 public static function _applyRetryConfig($value, $args, HandlerList $list)
833 {
834 if ($value) {
835 $config = \Aws\Retry\ConfigurationProvider::unwrap($value);
836
837 if ($config->getMode() === 'legacy') {
838 $maxRetries = $config->getMaxAttempts() - 1;
839 $decider = RetryMiddleware::createDefaultDecider($maxRetries);
840 $decider = function ($retries, $command, $request, $result, $error) use ($decider, $maxRetries) {
841 $maxRetries = null !== $command['@retries']
842 ? $command['@retries']
843 : $maxRetries;
844
845 if ($decider($retries, $command, $request, $result, $error)) {
846 return true;
847 }
848
849 if ($error instanceof AwsException
850 && $retries < $maxRetries
851 ) {
852 if ($error->getResponse()
853 && $error->getResponse()->getStatusCode() >= 400
854 ) {
855 return strpos(
856 $error->getResponse()->getBody(),
857 'Your socket connection to the server'
858 ) !== false;
859 }
860
861 if ($error->getPrevious() instanceof RequestException) {
862 // All commands except CompleteMultipartUpload are
863 // idempotent and may be retried without worry if a
864 // networking error has occurred.
865 return $command->getName() !== 'CompleteMultipartUpload';
866 }
867 }
868
869 return false;
870 };
871
872 $delay = [RetryMiddleware::class, 'exponentialDelay'];
873 $list->appendSign(Middleware::retry($decider, $delay), 'retry');
874 } else {
875 $defaultDecider = RetryMiddlewareV2::createDefaultDecider(
876 new QuotaManager(),
877 $config->getMaxAttempts()
878 );
879
880 $list->appendSign(
881 RetryMiddlewareV2::wrap(
882 $config,
883 [
884 'collect_stats' => $args['stats']['retries'],
885 'decider' => function(
886 $attempts,
887 CommandInterface $cmd,
888 $result
889 ) use ($defaultDecider, $config) {
890 $isRetryable = $defaultDecider($attempts, $cmd, $result);
891 if (!$isRetryable
892 && $result instanceof AwsException
893 && $attempts < $config->getMaxAttempts()
894 ) {
895 if (!empty($result->getResponse())
896 && $result->getResponse()->getStatusCode() >= 400
897 ) {
898 return strpos(
899 $result->getResponse()->getBody(),
900 'Your socket connection to the server'
901 ) !== false;
902 }
903
904 if ($result->getPrevious() instanceof RequestException
905 && $cmd->getName() !== 'CompleteMultipartUpload'
906 ) {
907 $isRetryable = true;
908 }
909 }
910
911 return $isRetryable;
912 }
913 ]
914 ),
915 'retry'
916 );
917 }
918 }
919 }
920
921 /** @internal */
922 public static function _applyApiProvider($value, array &$args, HandlerList $list)
923 {
924 ClientResolver::_apply_api_provider($value, $args);
925 $args['parser'] = new GetBucketLocationParser(
926 new ValidateResponseChecksumParser(
927 new AmbiguousSuccessParser(
928 new RetryableMalformedResponseParser(
929 $args['parser'],
930 $args['exception_class']
931 ),
932 $args['error_parser'],
933 $args['exception_class']
934 ),
935 $args['api']
936 )
937 );
938 }
939
940 /**
941 * @internal
942 * @codeCoverageIgnore
943 */
944 public static function applyDocFilters(array $api, array $docs)
945 {
946 $b64 = '<div class="alert alert-info">This value will be base64 encoded on your behalf.</div>';
947 $opt = '<div class="alert alert-info">This value will be computed for you it is not supplied.</div>';
948
949 // Add a note on the CopyObject docs
950 $s3ExceptionRetryMessage = "<p>Additional info on response behavior: if there is"
951 . " an internal error in S3 after the request was successfully recieved,"
952 . " a 200 response will be returned with an <code>S3Exception</code> embedded"
953 . " in it; this will still be caught and retried by"
954 . " <code>RetryMiddleware.</code></p>";
955
956 $docs['operations']['CopyObject'] .= $s3ExceptionRetryMessage;
957 $docs['operations']['CompleteMultipartUpload'] .= $s3ExceptionRetryMessage;
958 $docs['operations']['UploadPartCopy'] .= $s3ExceptionRetryMessage;
959 $docs['operations']['UploadPart'] .= $s3ExceptionRetryMessage;
960
961 // Add note about stream ownership in the putObject call
962 $guzzleStreamMessage = "<p>Additional info on behavior of the stream"
963 . " parameters: Psr7 takes ownership of streams and will automatically close"
964 . " streams when this method is called with a stream as the <code>Body</code>"
965 . " parameter. To prevent this, set the <code>Body</code> using"
966 . " <code>GuzzleHttp\Psr7\stream_for</code> method with a is an instance of"
967 . " <code>Psr\Http\Message\StreamInterface</code>, and it will be returned"
968 . " unmodified. This will allow you to keep the stream in scope. </p>";
969 $docs['operations']['PutObject'] .= $guzzleStreamMessage;
970
971 // Add the SourceFile parameter.
972 $docs['shapes']['SourceFile']['base'] = 'The path to a file on disk to use instead of the Body parameter.';
973 $api['shapes']['SourceFile'] = ['type' => 'string'];
974 $api['shapes']['PutObjectRequest']['members']['SourceFile'] = ['shape' => 'SourceFile'];
975 $api['shapes']['UploadPartRequest']['members']['SourceFile'] = ['shape' => 'SourceFile'];
976
977 // Add the ContentSHA256 parameter.
978 $docs['shapes']['ContentSHA256']['base'] = 'A SHA256 hash of the body content of the request.';
979 $api['shapes']['ContentSHA256'] = ['type' => 'string'];
980 $api['shapes']['PutObjectRequest']['members']['ContentSHA256'] = ['shape' => 'ContentSHA256'];
981 $api['shapes']['UploadPartRequest']['members']['ContentSHA256'] = ['shape' => 'ContentSHA256'];
982 $docs['shapes']['ContentSHA256']['append'] = $opt;
983
984 // Add the AddContentMD5 parameter.
985 $docs['shapes']['AddContentMD5']['base'] = 'Set to true to calculate the ContentMD5 for the upload.';
986 $api['shapes']['AddContentMD5'] = ['type' => 'boolean'];
987 $api['shapes']['PutObjectRequest']['members']['AddContentMD5'] = ['shape' => 'AddContentMD5'];
988 $api['shapes']['UploadPartRequest']['members']['AddContentMD5'] = ['shape' => 'AddContentMD5'];
989
990 // Add the SaveAs parameter.
991 $docs['shapes']['SaveAs']['base'] = 'The path to a file on disk to save the object data.';
992 $api['shapes']['SaveAs'] = ['type' => 'string'];
993 $api['shapes']['GetObjectRequest']['members']['SaveAs'] = ['shape' => 'SaveAs'];
994
995 // Several SSECustomerKey documentation updates.
996 $docs['shapes']['SSECustomerKey']['append'] = $b64;
997 $docs['shapes']['CopySourceSSECustomerKey']['append'] = $b64;
998 $docs['shapes']['SSECustomerKeyMd5']['append'] = $opt;
999
1000 // Add the ObjectURL to various output shapes and documentation.
1001 $docs['shapes']['ObjectURL']['base'] = 'The URI of the created object.';
1002 $api['shapes']['ObjectURL'] = ['type' => 'string'];
1003 $api['shapes']['PutObjectOutput']['members']['ObjectURL'] = ['shape' => 'ObjectURL'];
1004 $api['shapes']['CopyObjectOutput']['members']['ObjectURL'] = ['shape' => 'ObjectURL'];
1005 $api['shapes']['CompleteMultipartUploadOutput']['members']['ObjectURL'] = ['shape' => 'ObjectURL'];
1006
1007 // Fix references to Location Constraint.
1008 unset($api['shapes']['CreateBucketRequest']['payload']);
1009 $api['shapes']['BucketLocationConstraint']['enum'] = [
1010 "ap-northeast-1",
1011 "ap-southeast-2",
1012 "ap-southeast-1",
1013 "cn-north-1",
1014 "eu-central-1",
1015 "eu-west-1",
1016 "us-east-1",
1017 "us-west-1",
1018 "us-west-2",
1019 "sa-east-1",
1020 ];
1021
1022 // Add a note that the ContentMD5 is automatically computed, except for with PutObject and UploadPart
1023 $docs['shapes']['ContentMD5']['append'] = '<div class="alert alert-info">The value will be computed on '
1024 . 'your behalf.</div>';
1025 $docs['shapes']['ContentMD5']['excludeAppend'] = ['PutObjectRequest', 'UploadPartRequest'];
1026
1027 //Add a note to ContentMD5 for PutObject and UploadPart that specifies the value is required
1028 // When uploading to a bucket with object lock enabled and that it is not computed automatically
1029 $objectLock = '<div class="alert alert-info">This value is required if uploading to a bucket '
1030 . 'which has Object Lock enabled. It will not be calculated for you automatically. If you wish to have '
1031 . 'the value calculated for you, use the `AddContentMD5` parameter.</div>';
1032 $docs['shapes']['ContentMD5']['appendOnly'] = [
1033 'message' => $objectLock,
1034 'shapes' => ['PutObjectRequest', 'UploadPartRequest']
1035 ];
1036
1037 return [
1038 new Service($api, ApiProvider::defaultProvider()),
1039 new DocModel($docs)
1040 ];
1041 }
1042
1043 /**
1044 * @internal
1045 * @codeCoverageIgnore
1046 */
1047 public static function addDocExamples($examples)
1048 {
1049 $getObjectExample = [
1050 'input' => [
1051 'Bucket' => 'arn:aws:s3:us-east-1:123456789012:accesspoint:myaccesspoint',
1052 'Key' => 'my-key'
1053 ],
1054 'output' => [
1055 'Body' => 'class GuzzleHttp\Psr7\Stream#208 (7) {...}',
1056 'ContentLength' => '11',
1057 'ContentType' => 'application/octet-stream',
1058 ],
1059 'comments' => [
1060 'input' => '',
1061 'output' => 'Simplified example output'
1062 ],
1063 'description' => 'The following example retrieves an object by referencing the bucket via an S3 accesss point ARN. Result output is simplified for the example.',
1064 'id' => '',
1065 'title' => 'To get an object via an S3 access point ARN'
1066 ];
1067 if (isset($examples['GetObject'])) {
1068 $examples['GetObject'] []= $getObjectExample;
1069 } else {
1070 $examples['GetObject'] = [$getObjectExample];
1071 }
1072
1073 $putObjectExample = [
1074 'input' => [
1075 'Bucket' => 'arn:aws:s3:us-east-1:123456789012:accesspoint:myaccesspoint',
1076 'Key' => 'my-key',
1077 'Body' => 'my-body',
1078 ],
1079 'output' => [
1080 'ObjectURL' => 'https://my-bucket.s3.us-east-1.amazonaws.com/my-key'
1081 ],
1082 'comments' => [
1083 'input' => '',
1084 'output' => 'Simplified example output'
1085 ],
1086 'description' => 'The following example uploads an object by referencing the bucket via an S3 accesss point ARN. Result output is simplified for the example.',
1087 'id' => '',
1088 'title' => 'To upload an object via an S3 access point ARN'
1089 ];
1090 if (isset($examples['PutObject'])) {
1091 $examples['PutObject'] []= $putObjectExample;
1092 } else {
1093 $examples['PutObject'] = [$putObjectExample];
1094 }
1095
1096 return $examples;
1097 }
1098
1099 /**
1100 * @param CommandInterface $command
1101 * @return array|mixed|null
1102 */
1103 private function getSignatureVersionFromCommand(CommandInterface $command)
1104 {
1105 $signatureVersion = empty($command->getAuthSchemes())
1106 ? $this->getConfig('signature_version')
1107 : $command->getAuthSchemes()['version'];
1108 return $signatureVersion;
1109 }
1110
1111 }
1112