I am trying to upload csv file to my existing Amazon S3 bucket named 'my-bucketname' in python using boto
I get an error 'NoneType' object has no attribute 'set_contents_from_filename'
So i guess I am not able to establish connection properly with S3 bucket.
Could anyone help me with this?
Here is my code.
s3conn = boto.connect_s3(aws_access_key_id,aws_secret_access_key)
upload_file = '/home/csvfilename.csv'
key = s3conn.get_bucket('my-bucketname').get_key('csvfilename.csv')
key.set_contents_from_filename(upload_file)
UPDATED
s3Conn = boto.connect_s3(access_key,secret_key)
bucket2 = self.s3Conn.lookup('my-bucket-name')
k = Key(bucket2)
k.Key = "sg_details.csv"
k.set_contents_from_filename("sg_details.csv")
bucket2 = conn.lookup(bucketname)
k = Key(bucket2)
k.key = filename
k.set_contents_from_filename(filename)
print('Completed')
Try this, this should work properly. I am not sure why you used getkey
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments