Skip to content

Instantly share code, notes, and snippets.

@makotoworld
Created May 29, 2012 15:46
Show Gist options
  • Save makotoworld/2829159 to your computer and use it in GitHub Desktop.
Save makotoworld/2829159 to your computer and use it in GitHub Desktop.
Amazon S3 Memo (boto)
# DELETE
c = boto.connect_s3()
b = Bucket(c, 'deafway.jp')
list = b.get_all_keys()
for i in list:
if 'sign201' in i.name:
k = Key(b)
k.key = i.name
b.delete_key(k)
# UPLOAD
import boto
from boto.s3.key import Key
from boto.s3.bucket import Bucket
c = boto.connect_s3()
b = Bucket(c, 'deafway.jp') # Bucket Name
k = Key(b)
k.key = 'events/dy.jpg' # S3 Dir Name + FILE NAME
k.set_contents_from_filename('static/dy.jpg') #Server Dir Name + UPLOAD FILES NAME
k.make_public()
k.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment