12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109 |
- <?php
- namespace Aws\S3;
- use Aws\Api\ApiProvider;
- use Aws\Api\DocModel;
- use Aws\Api\Service;
- use Aws\AwsClient;
- use Aws\CacheInterface;
- use Aws\ClientResolver;
- use Aws\Command;
- use Aws\CommandInterface;
- use Aws\Configuration\ConfigurationResolver;
- use Aws\Exception\AwsException;
- use Aws\HandlerList;
- use Aws\Identity\S3\S3ExpressIdentityProvider;
- use Aws\InputValidationMiddleware;
- use Aws\Middleware;
- use Aws\ResultInterface;
- use Aws\Retry\QuotaManager;
- use Aws\RetryMiddleware;
- use Aws\RetryMiddlewareV2;
- use Aws\S3\RegionalEndpoint\ConfigurationProvider;
- use Aws\S3\UseArnRegion\Configuration;
- use Aws\S3\UseArnRegion\ConfigurationInterface;
- use Aws\S3\UseArnRegion\ConfigurationProvider as UseArnRegionConfigurationProvider;
- use GuzzleHttp\Exception\RequestException;
- use GuzzleHttp\Promise\PromiseInterface;
- use Psr\Http\Message\RequestInterface;
- class S3Client extends AwsClient implements S3ClientInterface
- {
- use S3ClientTrait;
-
- private static $mandatoryAttributes = ['Bucket', 'Key'];
- public static function getArguments()
- {
- $args = parent::getArguments();
- $args['retries']['fn'] = [__CLASS__, '_applyRetryConfig'];
- $args['api_provider']['fn'] = [__CLASS__, '_applyApiProvider'];
- return $args + [
- 'bucket_endpoint' => [
- 'type' => 'config',
- 'valid' => ['bool'],
- 'doc' => 'Set to true to send requests to a hardcoded '
- . 'bucket endpoint rather than create an endpoint as a '
- . 'result of injecting the bucket into the URL. This '
- . 'option is useful for interacting with CNAME endpoints.',
- ],
- 'use_arn_region' => [
- 'type' => 'config',
- 'valid' => [
- 'bool',
- Configuration::class,
- CacheInterface::class,
- 'callable'
- ],
- 'doc' => 'Set to true to allow passed in ARNs to override'
- . ' client region. Accepts...',
- 'fn' => [__CLASS__, '_apply_use_arn_region'],
- 'default' => [UseArnRegionConfigurationProvider::class, 'defaultProvider'],
- ],
- 'use_accelerate_endpoint' => [
- 'type' => 'config',
- 'valid' => ['bool'],
- 'doc' => 'Set to true to send requests to an S3 Accelerate'
- . ' endpoint by default. Can be enabled or disabled on'
- . ' individual operations by setting'
- . ' \'@use_accelerate_endpoint\' to true or false. Note:'
- . ' you must enable S3 Accelerate on a bucket before it can'
- . ' be accessed via an Accelerate endpoint.',
- 'default' => false,
- ],
- 'use_path_style_endpoint' => [
- 'type' => 'config',
- 'valid' => ['bool'],
- 'doc' => 'Set to true to send requests to an S3 path style'
- . ' endpoint by default.'
- . ' Can be enabled or disabled on individual operations by setting'
- . ' \'@use_path_style_endpoint\' to true or false.',
- 'default' => false,
- ],
- 'disable_multiregion_access_points' => [
- 'type' => 'config',
- 'valid' => ['bool'],
- 'doc' => 'Set to true to disable the usage of'
- . ' multi region access points. These are enabled by default.'
- . ' Can be enabled or disabled on individual operations by setting'
- . ' \'@disable_multiregion_access_points\' to true or false.',
- 'default' => false,
- ],
- 'disable_express_session_auth' => [
- 'type' => 'config',
- 'valid' => ['bool'],
- 'doc' => 'Set to true to disable the usage of'
- . ' s3 express session authentication. This is enabled by default.',
- 'default' => [__CLASS__, '_default_disable_express_session_auth'],
- ],
- 's3_express_identity_provider' => [
- 'type' => 'config',
- 'valid' => [
- 'bool',
- 'callable'
- ],
- 'doc' => 'Specifies the provider used to generate identities to sign s3 express requests. '
- . 'Set to `false` to disable s3 express auth, or a callable provider used to create s3 express '
- . 'identities or return null.',
- 'default' => [__CLASS__, '_default_s3_express_identity_provider'],
- ],
- ];
- }
-
- public function __construct(array $args)
- {
- if (
- !isset($args['s3_us_east_1_regional_endpoint'])
- || $args['s3_us_east_1_regional_endpoint'] instanceof CacheInterface
- ) {
- $args['s3_us_east_1_regional_endpoint'] = ConfigurationProvider::defaultProvider($args);
- }
- $this->addBuiltIns($args);
- parent::__construct($args);
- $stack = $this->getHandlerList();
- $stack->appendInit(SSECMiddleware::wrap($this->getEndpoint()->getScheme()), 's3.ssec');
- $stack->appendBuild(ApplyChecksumMiddleware::wrap($this->getApi()), 's3.checksum');
- $stack->appendBuild(
- Middleware::contentType(['PutObject', 'UploadPart']),
- 's3.content_type'
- );
- if ($this->getConfig('bucket_endpoint')) {
- $stack->appendBuild(BucketEndpointMiddleware::wrap(), 's3.bucket_endpoint');
- } elseif (!$this->isUseEndpointV2()) {
- $stack->appendBuild(
- S3EndpointMiddleware::wrap(
- $this->getRegion(),
- $this->getConfig('endpoint_provider'),
- [
- 'accelerate' => $this->getConfig('use_accelerate_endpoint'),
- 'path_style' => $this->getConfig('use_path_style_endpoint'),
- 'use_fips_endpoint' => $this->getConfig('use_fips_endpoint'),
- 'dual_stack' =>
- $this->getConfig('use_dual_stack_endpoint')->isUseDualStackEndpoint(),
- ]
- ),
- 's3.endpoint_middleware'
- );
- }
- $stack->appendBuild(
- BucketEndpointArnMiddleware::wrap(
- $this->getApi(),
- $this->getRegion(),
- [
- 'use_arn_region' => $this->getConfig('use_arn_region'),
- 'accelerate' => $this->getConfig('use_accelerate_endpoint'),
- 'path_style' => $this->getConfig('use_path_style_endpoint'),
- 'dual_stack' =>
- $this->getConfig('use_dual_stack_endpoint')->isUseDualStackEndpoint(),
- 'use_fips_endpoint' => $this->getConfig('use_fips_endpoint'),
- 'disable_multiregion_access_points' =>
- $this->getConfig('disable_multiregion_access_points'),
- 'endpoint' => $args['endpoint'] ?? null
- ],
- $this->isUseEndpointV2()
- ),
- 's3.bucket_endpoint_arn'
- );
- if ($this->getConfig('disable_express_session_auth')) {
- $stack->prependSign(
- $this->getDisableExpressSessionAuthMiddleware(),
- 's3.disable_express_session_auth'
- );
- }
- $stack->appendValidate(
- InputValidationMiddleware::wrap($this->getApi(), self::$mandatoryAttributes),
- 'input_validation_middleware'
- );
- $stack->appendSign(PutObjectUrlMiddleware::wrap(), 's3.put_object_url');
- $stack->appendSign(PermanentRedirectMiddleware::wrap(), 's3.permanent_redirect');
- $stack->appendInit(Middleware::sourceFile($this->getApi()), 's3.source_file');
- $stack->appendInit($this->getSaveAsParameter(), 's3.save_as');
- $stack->appendInit($this->getLocationConstraintMiddleware(), 's3.location');
- $stack->appendInit($this->getEncodingTypeMiddleware(), 's3.auto_encode');
- $stack->appendInit($this->getHeadObjectMiddleware(), 's3.head_object');
- if ($this->isUseEndpointV2()) {
- $this->processEndpointV2Model();
- $stack->after('builder',
- 's3.check_empty_path_with_query',
- $this->getEmptyPathWithQuery());
- }
- }
-
- public static function isBucketDnsCompatible($bucket)
- {
- if (!is_string($bucket)) {
- return false;
- }
- $bucketLen = strlen($bucket);
- return ($bucketLen >= 3 && $bucketLen <= 63) &&
-
- !filter_var($bucket, FILTER_VALIDATE_IP) &&
- preg_match('/^[a-z0-9]([a-z0-9\-\.]*[a-z0-9])?$/', $bucket);
- }
- public static function _apply_use_arn_region($value, array &$args, HandlerList $list)
- {
- if ($value instanceof CacheInterface) {
- $value = UseArnRegionConfigurationProvider::defaultProvider($args);
- }
- if (is_callable($value)) {
- $value = $value();
- }
- if ($value instanceof PromiseInterface) {
- $value = $value->wait();
- }
- if ($value instanceof ConfigurationInterface) {
- $args['use_arn_region'] = $value;
- } else {
-
- $args['use_arn_region'] = new Configuration($value);
- }
- }
- public function createPresignedRequest(CommandInterface $command, $expires, array $options = [])
- {
- $command = clone $command;
- $command->getHandlerList()->remove('signer');
- $request = \Aws\serialize($command);
- $signing_name = $command['@context']['signing_service']
- ?? $this->getSigningName($request->getUri()->getHost());
- $signature_version = $this->getSignatureVersionFromCommand($command);
-
- $signer = call_user_func(
- $this->getSignatureProvider(),
- $signature_version,
- $signing_name,
- $this->getConfig('signing_region')
- );
- if ($signature_version == 'v4-s3express') {
- $provider = $this->getConfig('s3_express_identity_provider');
- $credentials = $provider($command)->wait();
- } else {
- $credentials = $this->getCredentials()->wait();
- }
- return $signer->presign(
- $request,
- $credentials,
- $expires,
- $options
- );
- }
-
- public function getObjectUrl($bucket, $key)
- {
- $command = $this->getCommand('GetObject', [
- 'Bucket' => $bucket,
- 'Key' => $key
- ]);
- return (string) \Aws\serialize($command)->getUri();
- }
-
- public static function encodeKey($key)
- {
- return str_replace('%2F', '/', rawurlencode($key));
- }
-
- private function getLocationConstraintMiddleware()
- {
- $region = $this->getRegion();
- return static function (callable $handler) use ($region) {
- return function (Command $command, $request = null) use ($handler, $region) {
- if ($command->getName() === 'CreateBucket') {
- $locationConstraint = $command['CreateBucketConfiguration']['LocationConstraint']
- ?? null;
- if ($locationConstraint === 'us-east-1') {
- unset($command['CreateBucketConfiguration']);
- } elseif ('us-east-1' !== $region && empty($locationConstraint)) {
- $command['CreateBucketConfiguration'] = ['LocationConstraint' => $region];
- }
- }
- return $handler($command, $request);
- };
- };
- }
-
- private function getSaveAsParameter()
- {
- return static function (callable $handler) {
- return function (Command $command, $request = null) use ($handler) {
- if ($command->getName() === 'GetObject' && isset($command['SaveAs'])) {
- $command['@http']['sink'] = $command['SaveAs'];
- unset($command['SaveAs']);
- }
- return $handler($command, $request);
- };
- };
- }
-
- private function getHeadObjectMiddleware()
- {
- return static function (callable $handler) {
- return function (
- CommandInterface $command,
- RequestInterface $request = null
- ) use ($handler) {
- if ($command->getName() === 'HeadObject'
- && !isset($command['@http']['decode_content'])
- ) {
- $command['@http']['decode_content'] = false;
- }
- return $handler($command, $request);
- };
- };
- }
-
- private function getEncodingTypeMiddleware()
- {
- return static function (callable $handler) {
- return function (Command $command, $request = null) use ($handler) {
- $autoSet = false;
- if ($command->getName() === 'ListObjects'
- && empty($command['EncodingType'])
- ) {
- $command['EncodingType'] = 'url';
- $autoSet = true;
- }
- return $handler($command, $request)
- ->then(function (ResultInterface $result) use ($autoSet) {
- if ($result['EncodingType'] === 'url' && $autoSet) {
- static $topLevel = [
- 'Delimiter',
- 'Marker',
- 'NextMarker',
- 'Prefix',
- ];
- static $nested = [
- ['Contents', 'Key'],
- ['CommonPrefixes', 'Prefix'],
- ];
- foreach ($topLevel as $key) {
- if (isset($result[$key])) {
- $result[$key] = urldecode($result[$key]);
- }
- }
- foreach ($nested as $steps) {
- if (isset($result[$steps[0]])) {
- foreach ($result[$steps[0]] as $key => $part) {
- if (isset($part[$steps[1]])) {
- $result[$steps[0]][$key][$steps[1]]
- = urldecode($part[$steps[1]]);
- }
- }
- }
- }
- }
- return $result;
- });
- };
- };
- }
-
- private function getEmptyPathWithQuery()
- {
- return static function (callable $handler) {
- return function (Command $command, RequestInterface $request) use ($handler) {
- $uri = $request->getUri();
- if (empty($uri->getPath()) && !empty($uri->getQuery())) {
- $uri = $uri->withPath('/');
- $request = $request->withUri($uri);
- }
- return $handler($command, $request);
- };
- };
- }
-
- private function getDisableExpressSessionAuthMiddleware()
- {
- return function (callable $handler) {
- return function (
- CommandInterface $command,
- RequestInterface $request = null
- ) use ($handler) {
- if (!empty($command['@context']['signature_version'])
- && $command['@context']['signature_version'] === 'v4-s3express'
- ) {
- $command['@context']['signature_version'] = 's3v4';
- }
- return $handler($command, $request);
- };
- };
- }
-
- private function getSigningName($host)
- {
- if (strpos( $host, 's3-object-lambda')) {
- return 's3-object-lambda';
- }
- return $this->getConfig('signing_name');
- }
- public static function _default_disable_express_session_auth(array &$args) {
- return ConfigurationResolver::resolve(
- 's3_disable_express_session_auth',
- false,
- 'bool',
- $args
- );
- }
- public static function _default_s3_express_identity_provider(array $args)
- {
- if ($args['config']['disable_express_session_auth']) {
- return false;
- }
- return new S3ExpressIdentityProvider($args['region']);
- }
-
- private function processEndpointV2Model()
- {
- $definition = $this->getApi()->getDefinition();
- foreach($definition['operations'] as &$operation) {
- if (isset($operation['http']['requestUri'])) {
- $requestUri = $operation['http']['requestUri'];
- if ($requestUri === "/{Bucket}") {
- $requestUri = str_replace('/{Bucket}', '/', $requestUri);
- } else {
- $requestUri = str_replace('/{Bucket}', '', $requestUri);
- }
- $operation['http']['requestUri'] = $requestUri;
- }
- }
- $this->getApi()->setDefinition($definition);
- }
-
- private function addBuiltIns($args)
- {
- if (isset($args['region'])
- && $args['region'] !== 'us-east-1'
- ) {
- return false;
- }
- if (!isset($args['region'])
- && ConfigurationResolver::resolve('region', '', 'string') !== 'us-east-1'
- ) {
- return false;
- }
- $key = 'AWS::S3::UseGlobalEndpoint';
- $result = $args['s3_us_east_1_regional_endpoint'] instanceof \Closure ?
- $args['s3_us_east_1_regional_endpoint']()->wait() : $args['s3_us_east_1_regional_endpoint'];
- if (is_string($result)) {
- if ($result === 'regional') {
- $value = false;
- } else if ($result === 'legacy') {
- $value = true;
- } else {
- return;
- }
- } else {
- if ($result->isFallback()
- || $result->getEndpointsType() === 'legacy'
- ) {
- $value = true;
- } else {
- $value = false;
- }
- }
- $this->clientBuiltIns[$key] = $value;
- }
-
- public static function _applyRetryConfig($value, $args, HandlerList $list)
- {
- if ($value) {
- $config = \Aws\Retry\ConfigurationProvider::unwrap($value);
- if ($config->getMode() === 'legacy') {
- $maxRetries = $config->getMaxAttempts() - 1;
- $decider = RetryMiddleware::createDefaultDecider($maxRetries);
- $decider = function ($retries, $command, $request, $result, $error) use ($decider, $maxRetries) {
- $maxRetries = $command['@retries'] ?? $maxRetries;
- if ($decider($retries, $command, $request, $result, $error)) {
- return true;
- }
- if ($error instanceof AwsException
- && $retries < $maxRetries
- ) {
- if ($error->getResponse()
- && $error->getResponse()->getStatusCode() >= 400
- ) {
- return strpos(
- $error->getResponse()->getBody(),
- 'Your socket connection to the server'
- ) !== false;
- }
- if ($error->getPrevious() instanceof RequestException) {
-
-
-
- return $command->getName() !== 'CompleteMultipartUpload';
- }
- }
- return false;
- };
- $delay = [RetryMiddleware::class, 'exponentialDelay'];
- $list->appendSign(Middleware::retry($decider, $delay), 'retry');
- } else {
- $defaultDecider = RetryMiddlewareV2::createDefaultDecider(
- new QuotaManager(),
- $config->getMaxAttempts()
- );
- $list->appendSign(
- RetryMiddlewareV2::wrap(
- $config,
- [
- 'collect_stats' => $args['stats']['retries'],
- 'decider' => function(
- $attempts,
- CommandInterface $cmd,
- $result
- ) use ($defaultDecider, $config) {
- $isRetryable = $defaultDecider($attempts, $cmd, $result);
- if (!$isRetryable
- && $result instanceof AwsException
- && $attempts < $config->getMaxAttempts()
- ) {
- if (!empty($result->getResponse())
- && $result->getResponse()->getStatusCode() >= 400
- ) {
- return strpos(
- $result->getResponse()->getBody(),
- 'Your socket connection to the server'
- ) !== false;
- }
- if ($result->getPrevious() instanceof RequestException
- && $cmd->getName() !== 'CompleteMultipartUpload'
- ) {
- $isRetryable = true;
- }
- }
- return $isRetryable;
- }
- ]
- ),
- 'retry'
- );
- }
- }
- }
-
- public static function _applyApiProvider($value, array &$args, HandlerList $list)
- {
- ClientResolver::_apply_api_provider($value, $args);
- $args['parser'] = new GetBucketLocationParser(
- new ValidateResponseChecksumParser(
- new AmbiguousSuccessParser(
- new RetryableMalformedResponseParser(
- $args['parser'],
- $args['exception_class']
- ),
- $args['error_parser'],
- $args['exception_class']
- ),
- $args['api']
- )
- );
- }
-
- public static function applyDocFilters(array $api, array $docs)
- {
- $b64 = '<div class="alert alert-info">This value will be base64 encoded on your behalf.</div>';
- $opt = '<div class="alert alert-info">This value will be computed for you it is not supplied.</div>';
-
- $s3ExceptionRetryMessage = "<p>Additional info on response behavior: if there is"
- . " an internal error in S3 after the request was successfully recieved,"
- . " a 200 response will be returned with an <code>S3Exception</code> embedded"
- . " in it; this will still be caught and retried by"
- . " <code>RetryMiddleware.</code></p>";
- $docs['operations']['CopyObject'] .= $s3ExceptionRetryMessage;
- $docs['operations']['CompleteMultipartUpload'] .= $s3ExceptionRetryMessage;
- $docs['operations']['UploadPartCopy'] .= $s3ExceptionRetryMessage;
- $docs['operations']['UploadPart'] .= $s3ExceptionRetryMessage;
-
- $guzzleStreamMessage = "<p>Additional info on behavior of the stream"
- . " parameters: Psr7 takes ownership of streams and will automatically close"
- . " streams when this method is called with a stream as the <code>Body</code>"
- . " parameter. To prevent this, set the <code>Body</code> using"
- . " <code>GuzzleHttp\Psr7\stream_for</code> method with a is an instance of"
- . " <code>Psr\Http\Message\StreamInterface</code>, and it will be returned"
- . " unmodified. This will allow you to keep the stream in scope. </p>";
- $docs['operations']['PutObject'] .= $guzzleStreamMessage;
-
- $docs['shapes']['SourceFile']['base'] = 'The path to a file on disk to use instead of the Body parameter.';
- $api['shapes']['SourceFile'] = ['type' => 'string'];
- $api['shapes']['PutObjectRequest']['members']['SourceFile'] = ['shape' => 'SourceFile'];
- $api['shapes']['UploadPartRequest']['members']['SourceFile'] = ['shape' => 'SourceFile'];
-
- $docs['shapes']['ContentSHA256']['base'] = 'A SHA256 hash of the body content of the request.';
- $api['shapes']['ContentSHA256'] = ['type' => 'string'];
- $api['shapes']['PutObjectRequest']['members']['ContentSHA256'] = ['shape' => 'ContentSHA256'];
- $api['shapes']['UploadPartRequest']['members']['ContentSHA256'] = ['shape' => 'ContentSHA256'];
- $docs['shapes']['ContentSHA256']['append'] = $opt;
-
- $docs['shapes']['AddContentMD5']['base'] = 'Set to true to calculate the ContentMD5 for the upload.';
- $api['shapes']['AddContentMD5'] = ['type' => 'boolean'];
- $api['shapes']['PutObjectRequest']['members']['AddContentMD5'] = ['shape' => 'AddContentMD5'];
- $api['shapes']['UploadPartRequest']['members']['AddContentMD5'] = ['shape' => 'AddContentMD5'];
-
- $docs['shapes']['SaveAs']['base'] = 'The path to a file on disk to save the object data.';
- $api['shapes']['SaveAs'] = ['type' => 'string'];
- $api['shapes']['GetObjectRequest']['members']['SaveAs'] = ['shape' => 'SaveAs'];
-
- $docs['shapes']['SSECustomerKey']['append'] = $b64;
- $docs['shapes']['CopySourceSSECustomerKey']['append'] = $b64;
- $docs['shapes']['SSECustomerKeyMd5']['append'] = $opt;
-
- $docs['shapes']['ObjectURL']['base'] = 'The URI of the created object.';
- $api['shapes']['ObjectURL'] = ['type' => 'string'];
- $api['shapes']['PutObjectOutput']['members']['ObjectURL'] = ['shape' => 'ObjectURL'];
- $api['shapes']['CopyObjectOutput']['members']['ObjectURL'] = ['shape' => 'ObjectURL'];
- $api['shapes']['CompleteMultipartUploadOutput']['members']['ObjectURL'] = ['shape' => 'ObjectURL'];
-
- unset($api['shapes']['CreateBucketRequest']['payload']);
- $api['shapes']['BucketLocationConstraint']['enum'] = [
- "ap-northeast-1",
- "ap-southeast-2",
- "ap-southeast-1",
- "cn-north-1",
- "eu-central-1",
- "eu-west-1",
- "us-east-1",
- "us-west-1",
- "us-west-2",
- "sa-east-1",
- ];
-
- $docs['shapes']['ContentMD5']['append'] = '<div class="alert alert-info">The value will be computed on '
- . 'your behalf.</div>';
- $docs['shapes']['ContentMD5']['excludeAppend'] = ['PutObjectRequest', 'UploadPartRequest'];
-
-
- $objectLock = '<div class="alert alert-info">This value is required if uploading to a bucket '
- . 'which has Object Lock enabled. It will not be calculated for you automatically. If you wish to have '
- . 'the value calculated for you, use the `AddContentMD5` parameter.</div>';
- $docs['shapes']['ContentMD5']['appendOnly'] = [
- 'message' => $objectLock,
- 'shapes' => ['PutObjectRequest', 'UploadPartRequest']
- ];
- return [
- new Service($api, ApiProvider::defaultProvider()),
- new DocModel($docs)
- ];
- }
-
- public static function addDocExamples($examples)
- {
- $getObjectExample = [
- 'input' => [
- 'Bucket' => 'arn:aws:s3:us-east-1:123456789012:accesspoint:myaccesspoint',
- 'Key' => 'my-key'
- ],
- 'output' => [
- 'Body' => 'class GuzzleHttp\Psr7\Stream#208 (7) {...}',
- 'ContentLength' => '11',
- 'ContentType' => 'application/octet-stream',
- ],
- 'comments' => [
- 'input' => '',
- 'output' => 'Simplified example output'
- ],
- 'description' => 'The following example retrieves an object by referencing the bucket via an S3 accesss point ARN. Result output is simplified for the example.',
- 'id' => '',
- 'title' => 'To get an object via an S3 access point ARN'
- ];
- if (isset($examples['GetObject'])) {
- $examples['GetObject'] []= $getObjectExample;
- } else {
- $examples['GetObject'] = [$getObjectExample];
- }
- $putObjectExample = [
- 'input' => [
- 'Bucket' => 'arn:aws:s3:us-east-1:123456789012:accesspoint:myaccesspoint',
- 'Key' => 'my-key',
- 'Body' => 'my-body',
- ],
- 'output' => [
- 'ObjectURL' => 'https://my-bucket.s3.us-east-1.amazonaws.com/my-key'
- ],
- 'comments' => [
- 'input' => '',
- 'output' => 'Simplified example output'
- ],
- 'description' => 'The following example uploads an object by referencing the bucket via an S3 accesss point ARN. Result output is simplified for the example.',
- 'id' => '',
- 'title' => 'To upload an object via an S3 access point ARN'
- ];
- if (isset($examples['PutObject'])) {
- $examples['PutObject'] []= $putObjectExample;
- } else {
- $examples['PutObject'] = [$putObjectExample];
- }
- return $examples;
- }
-
- private function getSignatureVersionFromCommand(CommandInterface $command)
- {
- return $command['@context']['signature_version']
- ?? $this->getConfig('signature_version');
- }
- }
|