Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 region issue #33

Closed
awijnen opened this issue Dec 22, 2014 · 7 comments
Closed

S3 region issue #33

awijnen opened this issue Dec 22, 2014 · 7 comments
Assignees
Labels

Comments

@awijnen
Copy link

awijnen commented Dec 22, 2014

First off, awesome work on this plugin.

I did find an issue with getting slingshot to work with an S3 bucket that's not initialized to the default region (i.e. 'US Standard').

To make sure it was just a region issue, I tried following along with the simple example in the README an posting to 3 different S3 buckets, which are all under the same account, and have gotten the same CORS configuration.

First I added the directive server-side, added the AWS key and secret to Meteor.settings, and configured the S3 buckets. Then I used the uploader from the client using the console:

var t = document.getElementById('test').files[0]
File {webkitRelativePath: "", lastModified: 1393941506000, lastModifiedDate: Tue Mar 04 2014 14:58:26 GMT+0100 (CET), name: "bicycle_road.jpeg", type: "image/jpeg"…}
var uploader = new Slingshot.Upload("myFileUploads");
Slingshot.Upload {status: function, progress: function, uploaded: function, send: function, request: function…}
uploader.send(t, function(err, downloadUrl) {
if (err) {console.dir(err);} else {console.dir(downloadUrl);}
});

Here are the issues I ran into following along with the example in the README:

  1. S3 bucket region: Frankfurt
    console error log:
POST https://fotoposterdev.s3.amazonaws.com/ 400 (Bad Request)
VM3007:3 Meteor.makeErrorType.errorClassdetails: undefinederror: "Bad Request - 400"errorType: "Meteor.Error"message: "Failed to upload file to cloud storage [Bad Request - 400]"reason: "Failed to upload file to cloud storage"stack: (...)get stack: function () { [native code] }set stack: function () { [native code] }__proto__: _.extend._inherits.Middle 
  1. S3 bucket region: Oregon
    console error log:
 XMLHttpRequest cannot load https://fpawdev.s3.amazonaws.com/. The request was redirected to 'https://fpawdev.s3-us-west-2.amazonaws.com/', which is disallowed for cross-origin requests that require preflight.
VM3265:3 Meteor.makeErrorType.errorClassdetails: undefinederror: " - 0"errorType: "Meteor.Error"message: "Failed to upload file to cloud storage [ - 0]"reason: "Failed to upload file to cloud storage"stack: (...)get stack: function () { [native code] }set stack: function () { [native code] }__proto__: _.extend._inherits.Middle
  1. S3 bucket region: US Standard ==> SUCCESS
    console log:
Slingshot.Upload {status: function, progress: function, uploaded: function, send: function, request: function…}
VM3534:3 https://fptestdev.s3.amazonaws.com/undefined/bicycle_road.jpeg
@gsuess gsuess added the bug label Dec 22, 2014
@gsuess
Copy link
Contributor

gsuess commented Dec 22, 2014

Hey thanks for reporting.

You can workaround the Oregon problem for now by setting the domain parameter in the directive.

domain: "fpawdev.s3-us-west-2.amazonaws.com".

In a future release (0.3) this will change to:

bucketUrl: "https://fpawdev.s3-us-west-2.amazonaws.com"

As for Frankfurt there seems to be another issue. That data-center is pretty new. Will need to solve that with S3 tech-support.

@awijnen
Copy link
Author

awijnen commented Dec 22, 2014

Awesome, thanks for the fast response. Definitely looking forward to see what Amazon's support has to say regarding that Frankfurt issue, because the app is for a local (Belgian) printing company who's customers are all local.

@gsuess
Copy link
Contributor

gsuess commented Dec 22, 2014

Did you try the irish datacenter? AFAIK that doesn't even have the preflight issue due to the redirect. It used to have it some time ago, but then amazon fixed it.

@awijnen
Copy link
Author

awijnen commented Dec 22, 2014

i was actually just testing that :).. and that work as well! So I'll go over Ireland for now.

@gsuess
Copy link
Contributor

gsuess commented Dec 22, 2014

Did you have to override the domain for Ireland?

@awijnen
Copy link
Author

awijnen commented Dec 22, 2014

yes I did

@gsuess
Copy link
Contributor

gsuess commented Jan 11, 2015

The reason why Frankfurt doesn't work is because slingshot uses AWS Signature Version 2.

Any new regions after January 30, 2014 will support only Signature Version 4 and therefore all requests to those regions must be made with Signature Version 4.

So it needs an upgrade for the signing method.

I have totally missed the existence of the new signing method in the docs before.

@gsuess gsuess self-assigned this Jan 11, 2015
gsuess added a commit that referenced this issue Jan 11, 2015
@gsuess gsuess closed this as completed Jan 13, 2015
gsuess added a commit that referenced this issue Jan 17, 2015
gsuess added a commit that referenced this issue Aug 17, 2015
Updated README.md regarding issue #33 (S3 Region Issue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants