我正在尝试使用 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) 我想访问这个存储桶并下载存储桶中存在的所有对象。尽管此存储桶具有公共访问权限,但我是否需要任何类型的身份验证密钥?
谢谢!
还有另一种方法可以在不使用 boto 的情况下执行此操作:
import nexradaws
conn = nexradaws.NexradAwsInterface()
conn.get_avail_scans('2020', '01', '01', 'KLTX')
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句