【问题标题】:Cant Connect to nexrad aws s3 bucket using python boto3 module无法使用 python boto3 模块连接到 nexrad aws s3 存储桶
【发布时间】:2021-01-05 00:33:00
【问题描述】:

我正在尝试使用 python boto3 连接到 Nexrad aws 存储桶,但遇到以下问题:
1) 代码:

import boto3
s3 = boto3.resource('s3')

my_bucket = s3.Bucket('arn:aws:s3:::unidata-nexrad-level2-chunks')

for objects in my_bucket.objects.all():
    print(objects)

Output:
---------------------------------------------------------------------------
ParamValidationError                      Traceback (most recent call last)
<ipython-input-11-0d42db5d6462> in <module>()
      7 my_bucket = s3.Bucket('arn:aws:s3:::unidata-nexrad-level2-chunks')
      8 
----> 9 for objects in my_bucket.objects.all():
     10     print(objects)

11 frames
/usr/local/lib/python3.6/dist-packages/botocore/handlers.py in validate_bucket_name(params, **kwargs)
    226             'the regex "%s" or be an ARN matching the regex "%s"' % (
    227                 bucket, VALID_BUCKET.pattern, VALID_S3_ARN.pattern))
--> 228         raise ParamValidationError(report=error_msg)
    229 
    230 

ParamValidationError: Parameter validation failed:
Invalid bucket name "arn:aws:s3:::unidata-nexrad-level2-chunks": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$" or be an ARN matching the regex "^arn:(aws).*:s3:[a-z\-0-9]+:[0-9]{12}:accesspoint[/:][a-zA-Z0-9\-]{1,63}$"

我对要使用的 aws 存储桶名称感到困惑,因为这是文档 https://registry.opendata.aws/noaa-nexrad/ 中提到的名称

2) 我想访问此存储桶并下载存储桶中存在的所有对象。尽管此存储桶具有公共访问权限,但我是否需要任何类型的身份验证密钥?

谢谢!

【问题讨论】:

  • 我目前也有同样的问题......你有没有找到解决方案?
  • 是的,我已经发布了答案。

标签: python-3.x amazon-s3 boto3


【解决方案1】:

还有另一种不使用 boto 的方法:

import nexradaws
conn = nexradaws.NexradAwsInterface()
conn.get_avail_scans('2020', '01', '01', 'KLTX')

【讨论】:

    猜你喜欢
    • 2014-04-22
    • 2021-11-04
    • 1970-01-01
    • 2021-11-25
    • 2023-01-18
    • 1970-01-01
    • 1970-01-01
    • 2022-10-04
    • 1970-01-01
    相关资源
    最近更新 更多