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

Retry S3 uploads with different region when using signature V4. #697

Merged
merged 2 commits into from
Oct 28, 2015

Conversation

rolftimmermans
Copy link
Contributor

When uploading objects to S3 (or making other requests), it is possible to use the us-east-1 region (the default) so that a region does not have to be specified. However, this fails with signature version v4 (which is required for some regions), because the region is included in the Authorization header.

The returned error is AuthorizationHeaderMalformed. It actually contains the region the bucket is located in.

This patch uses the <Region> element in the returned error to update the region to the suggested region in order to be able to retry the request. This ensures that it is always possible to omit the region when using S3 in combination with signature v4.

@@ -43,7 +43,8 @@ function extractError(resp) {
if (data.Code) {
resp.error = util.error(new Error(), {
code: data.Code,
message: data.Message
message: data.Message,
region: data.Region
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be any changes needed in this file since the extractError in lib/services/s3.js will handle setting the region. This functionality is specific to S3 so would like to keep the logic contained there.

@chrisradek
Copy link
Contributor

@rolftimmermans
Thank you very much for your pull request! I've added a few comments, but overall your changes look good. Once the requested changes are made I'll merge this in.
Thanks!

@rolftimmermans
Copy link
Contributor Author

Thanks! I've addressed your comments.

chrisradek added a commit that referenced this pull request Oct 28, 2015
Retry S3 uploads with different region when using signature V4.
@chrisradek chrisradek merged commit 1138319 into aws:master Oct 28, 2015
@chrisradek
Copy link
Contributor

@rolftimmermans
Thank you! #697 is now merged and will be available through NPM in the next release. We really appreciate your contribution!

chrisradek added a commit that referenced this pull request Oct 29, 2015
@lock
Copy link

lock bot commented Sep 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants