I am attempting to upload files directly to the browser to S3 using evaporate js. I followed the tutorial at jqueryajaxphp.com but I am having a problem with the signature
Signature.php
<?php
$to_sign = $_GET['to_sign'];
$secret = 'AWS_SECRET';
$hmac_sha1 = hash_hmac('sha1', $to_sign, $secret, true);
$signature = base64_encode($hmac_sha1);
echo $signature;
Upload function
function largeFileUPload(file) {
var ins = new Evaporate({
signerUrl: './includes/s3-signature.php',
aws_key: "AWS_KEY_XXXXXXX",
bucket: 'bucket-name',
awsRegion: 'eu-west-1',
cloudfront: true,
aws_url: 'http://bucket-name.s3-accelerate.amazonaws.com',
// partSize: 10 * 1024 * 1024,
s3Acceleration: true,
computeContentMd5: true,
cryptoMd5Method: function (data) { return AWS.util.crypto.md5(data, 'base64'); },
cryptoHexEncodedHash256: function (data) { return AWS.util.crypto.sha256(data, 'hex'); }
});
// http://<?=$my_bucket?>.s3-<?=$region?>.amazonaws.com
ins.add({
name: 'evaporateTest' + Math.floor(1000000000*Math.random()) + '.' + file.name.replace(/^.*\./, ''),
file: file,
xAmzHeadersAtInitiate : {
'x-amz-acl': 'public-read'
},
signParams: {
foo: 'bar'
},
complete: function(r){
console.log('Upload complete');
},
progress: function(progress){
var progress = Math.floor(progress*100);
console.log(progress);
},
error: function(msg){
console.log(msg);
}
});
}
I am getting to following response from from the s3 end point
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
I have also tried the blueimp plugin but this fails with files over 200MB