Skip to content

Instantly share code, notes, and snippets.

@driedtoast
Created April 8, 2010 21:04
Show Gist options
  • Save driedtoast/360538 to your computer and use it in GitHub Desktop.
Save driedtoast/360538 to your computer and use it in GitHub Desktop.
from boto.s3.connection import S3Connection
from boto.s3.key import Key
bucketname = 'testbucket'
keyname = 'testkey'
conn = S3Connection()
bucket = None
## get bucket or create it
try:
bucket = conn.get_bucket(bucketname)
except Exception, e:
bucket = conn.create_bucket(bucketname)
## just use key name to delete
bucket.delete_key(keyname)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment