just a port from railscasts jquery file upload direct to s3 episode for reference