Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

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