I try to list the objects in one specific S3 bucket using this code:
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. What can I do?
CodePudding user response:
It should be
Bucket='my-bucket1'
for key in conn.list_objects(Bucket='my-bucket1', Prefix='NAME/OF/FOLDER/')['Contents']:
print(key['Key'])