Created
May 29, 2012 15:46
-
-
Save makotoworld/2829159 to your computer and use it in GitHub Desktop.
Amazon S3 Memo (boto)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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