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

Documentation should mention that specifying the endpoint is not really optional #95

Closed
boutell opened this issue Sep 30, 2012 · 5 comments
Milestone

Comments

@boutell
Copy link
Contributor

boutell commented Sep 30, 2012

I'm finding that putFile consistently reports a false success with a 307 redirect if the endpoint option is not specific to the region. Someone has already reported the issue with 307 being treated as success, but it should also be documented that you're not going to get very far without specifying the precise endpoint for your region rather than the generic one.

@domenic
Copy link
Contributor

domenic commented Sep 30, 2012

I never specify an endpoint, and everything works great to me. What setup are you using that you are constantly getting 307s? Something about regions? I'd appreciate more info.

Also, 307 is not a success code:

This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request.

Only 2xx class codes indicate success, so nothing outside that range should be treated as such. Perhaps that is what really needs to be specified better in the README.

@boutell
Copy link
Contributor Author

boutell commented Oct 5, 2012

What region is your bucket in? I bet it's in us-standard, so the endpoint you're getting by default is already the final one.

If you try to use the default endpoint with a bucket that lives in the US Oregon region (us-west-2), you get a 307 redirect pointing you there. Which would be OK except that the putFile() function (and the putStream function it depends on) doesn't resolve that automatically. Your callback is invoked without an error, but your file hasn't been uploaded. Without an error it looks like you're done, and confusion ensues.

One possible solution is for putStream to follow the redirect. But if putStream isn't going to follow the redirect and complete the job, then it should be documented that you can bypass all this pain just by specifying the right endpoint in the first place, like this:

knox.createClient({
key: process.env.S3_KEY,
secret: process.env.S3_SECRET,
bucket: 'mybucket',
endpoint: 'mybucket.s3-us-west-2.amazonaws.com'
});

Note that the endpoint option, if specified, requires you to include the bucket name in the endpoint hostname yourself, since that is otherwise prepended as part of generating the default value for the endpoint option.

FYI, I'm using a region other than the default us-standard region because I need read-after-write consistency, without which there's no certainty people can see the file as soon as AWS claims they have it. But of course folks in Europe and elsewhere have an even more compelling need to do so.

@boutell
Copy link
Contributor Author

boutell commented Oct 5, 2012

A 'region' option would be a nice alternative to assembling the endpoint hostname manually.

@domenic
Copy link
Contributor

domenic commented Oct 8, 2012

OK, I agree we should make this easier. A region option sounds good, and a pull request is welcome. Eventually we'll take care of this by fixing #66.

@boutell boutell mentioned this issue Oct 23, 2012
@domenic
Copy link
Contributor

domenic commented Oct 27, 2012

Fixed as part of #108.

@domenic domenic closed this as completed Oct 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants