简体   繁体   English

S3:无效的存储桶名称 - 存储桶名称必须与正则表达式匹配

[英]S3: Invalid bucket name - Bucket name must match the regex

I try to list the objects in one specific S3 bucket using this code:我尝试使用以下代码列出一个特定 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'])

But get this error:但是得到这个错误:

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}$"

I tried also some other ways (specifying the path to the S3 bucket) but nothing works.我还尝试了其他一些方法(指定 S3 存储桶的路径)但没有任何效果。 What can I do?我能做什么?

It should be它应该是

Bucket='my-bucket1'
for key in conn.list_objects(Bucket='my-bucket1', Prefix='NAME/OF/FOLDER/')['Contents']:
    print(key['Key'])

暂无
暂无

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

相关问题 ParamValidationError:参数验证失败:存储桶名称必须与正则表达式匹配 - ParamValidationError: Parameter validation failed: Bucket name must match the regex circle-ci 上的无效存储桶名称(部署到 AWS S3) - Invalid bucket name on circle-ci(Deploy to AWS S3 ) AWS Lambda 尝试将文件从 S3 存储桶复制到另一个 S3 存储桶时出现无效存储桶名称错误 - Invalid bucket name error when AWS Lambda tries to copy files from an S3 bucket to another S3 bucket 使用正则表达式从 aws s3 url 中提取存储桶名称 - Extract bucket name from aws s3 url using regex AWS s3 试图修复错误 s3.meta.client.head_bucket(Bucket=bucket_name) - AWS s3 trying to fix error s3.meta.client.head_bucket(Bucket=bucket_name) 错误:存储桶名称必须匹配正则表达式“^[a-zA-Z0-9.\-_]{1,255}$” - ERROR: Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$" 有没有办法使用 aws s3 ls cli 将 S3 存储桶名称添加到存储桶的递归列表中? - Is there a way to add the S3 bucket name to the recursive list of a bucket using aws s3 ls cli? S3 Bucket Key 名称是否需要文件扩展名? - Does S3 Bucket Key name require file extension? 无法从名称中包含特殊字符的 s3 存储桶复制文件 - Not able to copy file from s3 bucket with speacial character in name 断言具有 CDK 自动生成名称的特定 S3 存储桶的存在 - Assert for the existence of a specific S3 bucket with a CDK autogenerated name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM