I've copied above code and getting error for "s3.list_objects" in for loop, below error : NameError: name 's3' is not defined
Probably the author forget to change:
s3 on s3_resource
E.g.:
import boto3 s3_resource = boto3.resource('s3') new_bucket_name = "targetBucketName" bucket_to_copy = "sourceBucketName" for key in s3_resource.list_objects(Bucket=bucket_to_copy)['Contents']: files = key['Key'] copy_source = {'Bucket': "bucket_to_copy",'Key': files} s3_resource.meta.client.copy(copy_source, new_bucket_name, files) print(files)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I've copied above code and getting error for "s3.list_objects" in for loop, below error :
NameError: name 's3' is not defined
Probably the author forget to change:
E.g.: