I am working with this code now:
#!/usr/bin/env python import boto import boto.s3 from boto.s3.key import Key AWS_ACCESS_KEY_ID = '' AWS_SECRET_ACCESS_KEY = '' filename = 'test.zip' bucket_name = AWS_ACCESS_KEY_ID.lower() + '-mah-bucket' conn = boto.connect_s3(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) bucket = conn.create_bucket(bucket_name, location=boto.s3.connection.Location.DEFAULT) k = Key(bucket) k.key = 'my test file' k.set_contents_from_filename(filename)
I have two questions. Firstly, I believe that this code creates a bucket and also does the loading. The fact is that I do not want to create a bucket, because I already have one in its place. To do this, I just change it to this:
k = Key(bucket_name)
and get rid of this:
bucket = conn.create_bucket(bucket_name, location=boto.s3.connection.Location.DEFAULT)
Jimmy source share