static - Upload to S3 and copy link tool


I use a script to upload files to an S3 bucket and copy the link to the clipboard. Basically:

static <file> [<s3path>]


jbenet @ lorien : /tmp % static 24898.png nocturne.png
> cat 24898.png | pyhash sha1
> echo "" | pbcopy
> aws s3 cp --profile juanbenet "24898.png" "s3://jbenet.static/d7b220c/nocturne.png"
> afplay /System/Library/Sounds/Ping.aiff

How it works:

  1. hash (sha1) the file for the url
  2. http://<bucket><sha1>/<s3path or basename(<file>)>
  3. copy the url to clipboard; done before upload, so you can paste right away
  4. upload the file to the s3 bucket
  5. play a sound to announce completion


# install pyhash
curl -o pyhash
chmod +x pyhash
sudo mv pyhash /usr/bin/pyhash

# install static
curl > static
chmod +x static
sudo mv static /usr/bin/static