'S3' object has no attribute 'Bucket'

I'm receiving this error 'S3' object has no attribute 'Bucket' any idea? below is my code

self.client = boto3.client( 's3', aws_access_key_id= access_key, aws_secret_access_key= secret ) the_bucket = self.client.Bucket('my_bucket') # but I'm receiving an error here 
2

1 Answer

There is more than one way to interact with Boto3.

The high-level one using resource() and classes like S3.Bucket. And the low-level one using boto3.client(...). You are kind of mixing these two.

If you look here it will clarify the difference. In short...

High-level example

s3 = boto3.resource('s3') the_bucket = s3.Bucket('my_bucket') 

Low-level example

self.client = boto3.client(...) self.client.create_bucket(...) 
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like