-
-
Save mostlygeek/5688650 to your computer and use it in GitHub Desktop.
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
import urllib2 | |
import boto | |
import re | |
import sys | |
from boto.s3.key import Key | |
if len(sys.argv) != 3: | |
print "Usage: s3-download.py s3://bucket/path localfile" | |
sys.exit(-1) | |
s3_url=sys.argv[1] | |
installer_jar=sys.argv[2] | |
r=re.search('s3://([^/]+)(.*)', s3_url) | |
if r == None: | |
raise "Malformed S3 URL" | |
s3_bucket=r.group(1) | |
s3_path=r.group(2) | |
c = boto.connect_s3() | |
b = c.get_bucket(s3_bucket) | |
k = Key(b) | |
k.key = s3_path | |
print "downloading from S3 {0} to {1}".format(s3_url, installer_jar) | |
k.get_contents_to_filename(installer_jar) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment