简体   繁体   English

如何在us-east-2中列出存储桶的AWS S3文件?

[英]How do I list AWS S3 files for a bucket in us-east-2?

I'm fully aware that S3 is region agnostic and that it shouldn't matter that the rest of our system is in us-east-2, but... 我完全知道S3是区域不可知的,并且我们系统的其余部分在us-east-2中都没有关系,但是...

If I try to initialize without a signature or regionm it tells me that I'm now required to use the v4 signature: 如果我尝试不使用签名或regionm进行初始化,则会告诉我现在需要使用v4签名:

php > $s3Client = \Aws\S3\S3Client::factory(array('key' => 'ACCESS', 'secret' => 'SECRET', 'version' => '2006-03-01'));
php > $objects = $s3Client->getListObjectsIterator(array('Bucket'=>'my-bucket')); foreach ($objects as $object) { echo $object['Key'] . "\n"; };

Warning: Uncaught Aws\S3\Exception\InvalidRequestException: AWS Error Code: InvalidRequest, Status Code: 400, AWS Request ID: REQUEST, AWS Error Type: client, AWS Error Message: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256., User-Agent: aws-sdk-php2/2.7.0 Guzzle/3.9.2 curl/7.54.0 PHP/7.1.23 ITR
  thrown in phar:///Library/WebServer/lib/aws.phar/Aws/Common/Exception/NamespaceExceptionFactory.php on line 91

I try to initialize S3 without a region: 我尝试初始化没有区域的S3:

php > $s3Client = \Aws\S3\S3Client::factory(array('key' => 'ACCESS', 'secret' => 'SECRET', 'signature' => 'v4'));

Warning: Uncaught Aws\Common\Exception\InvalidArgumentException: A region must be specified when using signature version 4 in phar:///Library/WebServer/aws.phar/Aws/S3/S3Client.php:283
Stack trace:
#0 phar:///Library/WebServer/aws.phar/Aws/S3/S3Client.php(171): Aws\S3\S3Client::createSignature(Array)
#1 php shell code(1): Aws\S3\S3Client::factory(Array)
#2 {main}
  thrown in phar:///Library/WebServer/aws.phar/Aws/S3/S3Client.php on line 283

Alright that makes sense, I guess I have to supply a region even though S3 doesn't require a region... 好吧,我想我必须提供一个区域,即使S3不需要区域...

php > $s3Client = \Aws\S3\S3Client::factory(array('key' => 'ACCESS', 'secret' => 'SECRET', 'signature' => 'v4', 'region' => 'us-east-1'));
php > $objects = $s3Client->getListObjectsIterator(array('Bucket'=>'my-bucket', 'Region' => 'us-east-1')); foreach ($objects as $object) { echo $object['Key'] . "\n"; };

Warning: Uncaught Aws\S3\Exception\S3Exception: AWS Error Code: AuthorizationHeaderMalformed, Status Code: 400, AWS Request ID: REQUEST, AWS Error Type: client, AWS Error Message: The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'us-east-2', User-Agent: aws-sdk-php2/2.6.15 Guzzle/3.9.2 curl/7.54.0 PHP/7.1.23 ITR
  thrown in phar:///Library/WebServer/aws.phar/Aws/Common/Exception/NamespaceExceptionFactory.php on line 91

Oh... oh... ok. 哦哦好的 I guess I need to use us-east-2 since the rest of our servers and services are built on us-east-2... 我想我需要使用us-east-2,因为我们其余的服务器和服务都建立在us-east-2上。

php > $s3Client = \Aws\S3\S3Client::factory(array('key' => 'ACCESS', 'secret' => 'SECRET', 'signature' => 'v4', 'region' => 'us-east-2'));

Warning: Uncaught Aws\Common\Exception\InvalidArgumentException: us-east-2 is not a valid region for Amazon Simple Storage Service in phar:///Library/WebServer/aws.phar/Aws/Common/Client/AbstractClient.php:131
Stack trace:
#0 phar:///Library/WebServer/aws.phar/Aws/Common/Client/ClientBuilder.php(394): Aws\Common\Client\AbstractClient::getEndpoint(Object(Guzzle\Service\Description\ServiceDescription), 'us-east-2', 'https')
#1 phar:///Library/WebServer/aws.phar/Aws/Common/Client/ClientBuilder.php(204): Aws\Common\Client\ClientBuilder->updateConfigFromDescription(Object(Guzzle\Common\Collection))
#2 phar:///Library/WebServer/aws.phar/Aws/S3/S3Client.php(207): Aws\Common\Client\ClientBuilder->build()
#3 php shell code(1): Aws\S3\S3Client::factory(Array)
#4 {main}
  thrown in phar:///Library/WebServer/aws.phar/Aws/Common/Client/AbstractClient.php on line 131

Then why would you tell me to use us-east-2 AWS?!? 那你为什么要告诉我使用us-east-2 AWS?!?

My aws.phar is version 2.6.15. 我的aws.phar是2.6.15版。

This was a known issue with AWS PHP SDK in 2.xx versions. 这是2.xx版本的AWS PHP SDK的一个已知问题。 You will need to upgrade the SDK to 2.8.x and above. 您需要将SDK升级到2.8.x及更高版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python Boto3 在 us-east-1 和 us-east-2 中存储桶的 AWS S3 预签名 url 响应存在差异 - Python Boto3 there is a difference in AWS S3 presign url response for bucket in us-east-1 and us-east-2 在us-east-2中将DynamoDB导出到S3 AWS Data Pipeline - Export DynamoDB to S3 AWS Data Pipeline in us-east-2 跨 AWS 区域迁移:us-east-1 到 us-east-2 - Moving Across AWS Regions: us-east-1 to us-east-2 AWS Codebuild - UPLOAD_ARTIFACTS 阶段出错:BucketRegionError:区域不正确,存储桶不在端点的“us-east-2”区域 - AWS Codebuild - Error in UPLOAD_ARTIFACTS phase: BucketRegionError: incorrect region, the bucket is not in 'us-east-2' region at endpoint 如何强制 AWS .NET SDK 为 S3 使用 us-east-1 区域端点而不是旧的全局端点? - How do I force the AWS .NET SDK to utilize the us-east-1 regional endpoint for S3 rather than the legacy global endpoint? rclone - 如何列出 AWS S3 存储桶中具有最新文件的目录? - rclone - How do I list which directory has the latest files in AWS S3 bucket? 是否可以使用 AWS Python Boto3 在 us-east-1 中创建 S3 存储桶 - Is it possible to create a S3 Bucket in us-east-1 using AWS Python Boto3 如何从 us-east-1 帐户访问在 us-west-2 区域创建的 S3 存储桶? - How to access S3 bucket created in us-west-2 region from us-east-1 account? 在us-east-2区域的AWS控制台中找不到“删除备份”选项 - “Delete Backup” Option is not found in AWS Console in us-east-2 region aws ec2 us-east-2是无效的区域选择 - aws ec2 us-east-2 is an invalid region choice
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM