Skip to content

Instantly share code, notes, and snippets.

@ian-su-sirca
Created December 20, 2013 01:08
Show Gist options
  • Select an option

  • Save ian-su-sirca/8048936 to your computer and use it in GitHub Desktop.

Select an option

Save ian-su-sirca/8048936 to your computer and use it in GitHub Desktop.
Upload api docs to S3
#!/usr/bin/env python
import boto.s3
from boto.s3.key import Key
import os
region = 'ap-southeast-2'
bucket = 'docs.sense-t.sirca.org.au'
folder = 'api'
s3 = boto.s3.connect_to_region(region)
b = s3.get_bucket(bucket)
if b is None:
print "No such bucket %s" % bucket
for f in os.listdir('.'):
if os.path.isfile(f) and (f.endswith('.html') or f.endswith('.css')):
uf = "%s/%s" % (folder, f)
print "Uploading to %s" % uf
key = Key(b)
key.key = uf
key.set_contents_from_filename(f)
key.set_acl('public-read')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment