我尝试使用以下代码在一个特定的S3桶中列出对象:
conn = client('s3') # again assumes boto.cfg setup, assume AWS S3
for key in conn.list_objects(Bucket='arn:aws:s3:::my-bucket1/NAME/OF/FOLDER/')['Contents']:
print(key['Key'])
但是得到这个错误:
Invalid bucket name "arn:aws:s3:::my-bucket1/NAME/OF/FOLDER/": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$" or be an ARN matching the regex "^arn:(aws).*:(s3|s3-object-lambda):[a-z\-0-9]*:[0-9]{12}:accesspoint[/:][a-zA-Z0-9\-.]{1,63}$|^arn:(aws).*:s3-outposts:[a-z\-0-9]+:[0-9]{12}:outpost[/:][a-zA-Z0-9\-]{1,63}[/:]accesspoint[/:][a-zA-Z0-9\-]{1,63}$"
我还尝试了其他一些方法(指定到S3桶的路径),但是没有任何效果。我能做什么?
发布于 2022-04-27 10:25:59
它应该是
Bucket='my-bucket1'
for key in conn.list_objects(Bucket='my-bucket1', Prefix='NAME/OF/FOLDER/')['Contents']:
print(key['Key'])
https://stackoverflow.com/questions/72027152
复制相似问题