Skip to content

Instantly share code, notes, and snippets.

@futoase
Created November 27, 2012 08:32
Show Gist options
  • Save futoase/4153135 to your computer and use it in GitHub Desktop.
Save futoase/4153135 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# http://stackoverflow.com/questions/3140779/how-to-delete-files-from-amazon-s3-bucket
import sys
from boto.s3.connection import S3Connection
from boot.s3.bucket import Bucket
ACCESS_KEY = ''
SECRET_KEY = ''
if __name__ == '__main__':
if (sys.argv) == 1:
sys.exit(1)
con = S3Connection(ACCESS_KEY, SECRET_KEY)
b = Bucket(con, sys.argv[1])
for x in b.list():
b.delete_key(x.key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment