Created
April 29, 2015 15:15
-
-
Save stuartlynn/d802daa871ca4972e3da to your computer and use it in GitHub Desktop.
Gits for creating an upload to s3 site
This file contains 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
<html> | |
<head> | |
<title>S3 POST Form</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
</head> | |
<body> | |
<form action="https://zooniverse-data.s3.amazonaws.com/" method="post" enctype="multipart/form-data"> | |
<input type="hidden" name="key" value="cruk_upload/${filename}"> | |
<input type="hidden" name="AWSAccessKeyId" value={AWSAccessKeyId}> | |
<input type="hidden" name="acl" value="private"> | |
<input type="hidden" name="success_action_redirect" value="http://zooniverse-data.s3.amazonaws.com/cruk_upload/success.html"> | |
<input type="hidden" name="policy" value={insert_base64_policy_here}> | |
<input type="hidden" name="signature" value={insert_signature_here> | |
<!-- Include any additional input fields here --> | |
File to upload to S3: | |
<input name="file" type="file"> | |
<br> | |
<input type="submit" value="Upload File to S3"> | |
</form> | |
</body> | |
</html> |
This file contains 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
{"expiration": "2016-01-01T00:00:00Z", | |
"conditions": [ | |
{"bucket": "zooniverse-data"}, | |
["starts-with", "$key", "cruk_upload/"], | |
{"acl": "private"}, | |
{"success_action_redirect": "http://zooniverse-data.s3.amazonaws.com/cruk_upload/success.html"} | |
] | |
} |
This file contains 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
require 'base64' | |
require 'openssl' | |
require 'digest/sha1' | |
policy = Base64.encode64(IO.read("policy_doc")).gsub("\n","") | |
signature = Base64.encode64( | |
OpenSSL::HMAC.digest( | |
OpenSSL::Digest::Digest.new('sha1'), | |
ENV["AWS_SECRET_ACCESS_KEY"], policy) | |
).gsub("\n","") | |
File.open("b64_policy", "w"){ |f| f.puts policy} | |
File.open("signature", "w"){ |f| f.puts signature} | |
puts "policy #{policy}" | |
puts "signature #{signature}" |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title></title> | |
<!-- Bootstrap --> | |
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"> | |
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet"> | |
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> | |
<!-- WARNING: Respond.js doesn't work if you view the page via file:// --> | |
<!--[if lt IE 9]> | |
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> | |
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> | |
<![endif]--> | |
</head> | |
<body> | |
<h1>That worked thanks</h1> | |
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
<!-- Include all compiled plugins (below), or include individual files as needed --> | |
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment