Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Upload subdirs properly
Browse files Browse the repository at this point in the history
  • Loading branch information
powdahound committed Nov 23, 2012
1 parent 2ab12b9 commit dd5a010
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ def create_bucket():
bucket = conn.create_bucket(bucket_name, policy='public-read')
bucket.configure_website('index.html', 'error.html')

def deploy(dir='www'):
def deploy(root_dir='www'):
conn = connect_s3()
bucket = conn.get_bucket(bucket_name)

for root, dirs, files in os.walk(dir):
for root, dirs, files in os.walk(root_dir):
for name in files:
filename = os.path.join(root, name)
print 'Uploading %s' % filename
if name.startswith('.'):
continue
local_path = os.path.join(root, name)
remote_path = local_path[len(root_dir)+1:]
print '%s -> %s/%s' % (local_path, bucket_name, remote_path)
k = Key(bucket)
k.key = name
k.key = remote_path
headers = {}
k.set_contents_from_filename(filename, headers=headers,
k.set_contents_from_filename(local_path, headers=headers,
policy='public-read')

def delete():
Expand Down

0 comments on commit dd5a010

Please sign in to comment.