Last active
December 16, 2015 04:49
-
-
Save aaronjgreenberg/5379683 to your computer and use it in GitHub Desktop.
Uploads a file to your Amazon S3 bucket and then copies the access URL to your clipboard.
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 sys | |
import os.path | |
import subprocess | |
import boto | |
filename = sys.argv[1] | |
basename = os.path.basename(filename) | |
base_url = 'http://<bucket-name>.s3.amazonaws.com' | |
s3 = boto.connect_s3() | |
bucket = s3.get_bucket('<bucket-name>') | |
upload_key = bucket.new_key(basename) | |
upload_key.set_contents_from_filename(filename) | |
upload_key.set_acl('public-read') | |
access_url = os.path.join(base_url, upload_key.key) | |
pasteboard = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE) | |
pasteboard.stdin.write(access_url) | |
pasteboard.stdin.close() | |
pasteboard.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment