Closed Flynsarmy closed 9 years ago
The fix for this is changing line 1104 of mule-uploader.js from
self.headers['host'] = "s3.amazonaws.com";
to
self.headers['host'] = "s3-<region>.amazonaws.com";
// eg self.headers['host'] = "s3-ap-southeast-2.amazonaws.com";
This doesn't seem to work properly:
If I go to http://s3-ap-northeast-1.amazonaws.com/mule-uploader-demo/943773
, it gives me a redirect to http://s3.amazonaws.com/mule-uploader-demo/943773
. But s3-us-east-1.amazonaws.com
doesn't even exist!. So the proper fix, as I see it, is to re-try the query to the correct URL given by the 301 response.
Fairly sure it does. It's in the docs http://docs.aws.amazon.com/general/latest/gr/rande.html Check the Amazon Simple Storage Service (S3) section. Using http://s3.amazonaws.com only works for the US and nowhere else.
Here's more: http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro
Every region has a s3-... name, but the US Standard, which is s3.amazonaws.com. Flynarmy's changes fix the issue for every other region (mine stopped working until I applied his changes) but it won't work with US Standard.
I'd suggest to use Flynarmy's changes with a minimal correction: Instead of using
location.protocol + "//s3-" + settings.region + ".amazonaws.com/" + settings.bucket);
remove the - from the //s3 to
location.protocol + "//s3" + settings.region + ".amazonaws.com/" + settings.bucket);
This should work with all regions, and now if you are out of US Standard, you add a - to the beginning of the region name. Another fix would be to completely remove the s3 part and include it in the region (s3 for US Standard, s3-eu-west-1 for Ireland, etc).
This should be fixed by #45 (tested in US, Tokyo and Sao Paulo). I'll close this for now and reopen it if there are any other issues. Thanks for the input everyone!
Using the PHP uploader, I get two requests in my dev tools when uploading a file. The first is to _http://localhost/mule-uploader/php_backend/backend/signing_key_ which works fine and returns its JSON result but the second is to _http://s3.amazonaws.com/my.bucket/579989?uploads=&X-Amz-Date=20150105T040252Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=86400&X-Amz-Credential=foo%2Fap-southeast-2%2Fs3%2Faws4_request&X-Amz-SignedHeaders=Content-Disposition%3BContent-Type%3Bhost%3Bx-amz-acl&X-Amz-Signature=mysig_. This second request returns a status code of 301 Moved Permanently.