I'm just not getting this aws s3 to work. Tried several things now, including examples for angular (I don't want to use fineUploader!) and every time I get kind of the same errors. Right now I've got a pretty solid example of what needs to be done to get my error:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-sha256.js"> </script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/enc-base64-min.js"></script>
<script>
var POLICY_JSON = { "expiration": "2014-12-20T12:00:00.000Z",
"conditions": [
{"bucket": "<AWS_BUCKET_NAME>"},
["starts-with", "$key", "russ"],
{"acl": "public-read"},
{"success_action_redirect": "http://localhost:3000/successful_upload.html"},
["starts-with", "$Content-Type", "image/"]
]};
var policyBase64 = btoa((JSON.stringify(POLICY_JSON)));
console.log('<POLICY> -->');
console.log(policyBase64);
var hash = CryptoJS.HmacSHA256(policyBase64, "<AWS_SECRET_KEY>");
var base64 = CryptoJS.enc.Base64.stringify(hash);
console.log('<SIGNATURE> -->');
console.log(base64);
</script>
<form action="http://bucket.s3.amazonaws.com" method="post" enctype="multipart/form-data">
<input type="hidden" name="acl" value="public-read" />
<input type="hidden" name="success_action_redirect" value="http://localhost:3000/successful_upload.html" />
<input type="hidden" name="AWSAccessKeyId" value="<AWS_ACCESS_KEY>" />
<input type="hidden" name="Policy" value="<POLICY>" />
<input type="hidden" name="Signature" value="<SIGNATURE>" />
Key to upload: <input type="input" name="key" value="test.jpg" /><br />
Content-Type: <input type="input" name="Content-Type" value="image/jpeg" /><br />
File: <input type="file" name="file" /> <br />
<input type="submit" name="submit" value="Upload to Amazon S3" />
</form>
</body>
</html>
Copy everything into a new .html file and open it once, to get the values into your console, fillout the form with the values that come out and open the index.html again. My big problem is the answer I get every time I try to upload something to our bucket.
<Error>
<Code>InvalidRequest</Code>
<Message>
The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.
</Message>
<RequestId><MYREQUESTID></RequestId>
<HostId>
<MYHOSTID>
</HostId>
</Error>
Any suggestions? I'm working on this for 2 days now, searching and reading the amazon-documentation. It has to do with the signature I need to do (the new one aws uses seems to be named 'v4') and is used for the bucket since it's located in Frankfurt, Germany. But I'm just not getting how I can enhance my request to fit their needs.