5👍
So I solved this, and hopefully this will help some other people (nobody else seems to have this problem though, so maybe my setup is just different). My issue turned out to be with the s3upload.js library. Two things:
- I wanted to do authenticated-read, which in the example sign_s3 view was set to public-read. Just changing it in the view doesn’t help–x-amz-acl:public-read is also hardcoded in s3upload.js, in the function uploadToS3 (line 107). So you have to change this to match your view, otherwise I think the signature encoding never matches the CORS request headers.
-
The special characters =, +, and / were killing me. They are mentioned at the bottom of this Amazon S3 article as things to watch out for, so I made sure the hashing algorithm replaced them. The issue is that even though my hashing algorithm in my view was correctly replacing those three characters with the escape characters, s3upload was decoding and recoding them as =, +, and /. I changed one line in executeOnSignedUrl (line 71):
return callback(result.signed_request, result.url); //return callback(decodeURIComponent(result.signed_request), result.url);
And now it magically works! Note that this is very similar to this SO solution, just specific to the s3upload.js library.
As a side note–S3 also does not seem to like spaces in the key names (I did read this somewhere in Amazon documentation, I think), which was a separate problem I had…