I am trying to run a code snippet like this:
s3_file_path = "testunzipping/sample.csv.gz"
s3 = boto3.client('s3')
lst = s3.list_objects(Bucket='testunzipping')['Contents']
firstbucket = s3.Bucket('testunzipping')
but I am getting an error on the last line that:
"errorMessage": "'S3' object has no attribute 'Bucket'",
Later I am using the first bucket like this:
firstbucket.upload_fileobj(destination_file_gz, s3_filename)
What am I doing incorrect? I also tried with bucket
instead of Bucket
CodePudding user response:
There is a difference between boto.client
and boto.resource
.Bucket
is only defined on the latter:
s3_resource = boto3.resource('s3')
bucket = s3.Bucket('name')
vs.
s3_client = boto3.client('s3')
s3.list_objects(...)