Fix presigned_url to read virtual_host and bucket_as_host from config#313
Open
pepicrft wants to merge 3 commits intoex-aws:mainfrom
Open
Fix presigned_url to read virtual_host and bucket_as_host from config#313pepicrft wants to merge 3 commits intoex-aws:mainfrom
pepicrft wants to merge 3 commits intoex-aws:mainfrom
Conversation
…rom config When virtual_host and bucket_as_host are set in the ExAws config, the presigned_url and presigned_post functions were ignoring these settings and defaulting to false, causing bucket names to appear twice in URLs. Now these functions will use the config values as defaults, while still allowing explicit options to override them. Fixes the double bucket name issue when using custom domain buckets with bucket_as_host=true and virtual_host=true in the config.
Contributor
|
Thanks @pepicrft - the changes look good, but a couple of the tests fail - from the look of it the |
The refute assertions were incorrectly matching because they checked the full URL string for substrings like "/my-custom-domain.com/path" which would match "/path" in the legitimate URL path. Fixed by parsing the URL and checking uri.path specifically, ensuring we validate that the bucket name does not appear in the path component (which would indicate the duplication bug).
Contributor
Author
|
@bernardd I addressed your comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves: #306
Problem
When
virtual_hostandbucket_as_hostare set in the ExAws configuration, thepresigned_urlandpresigned_postfunctions ignore these settings and default tofalse. This causes bucket names to appear twice in generated URLs when using custom domain buckets.Example issue:
virtual_host: true, bucket_as_host: truehttps://my-bucket.com/my-bucket.com/path/to/filehttps://my-bucket.com/path/to/fileThis breaks multipart uploads and other S3 operations when using custom domains.
Root Cause
The
presigned_urlandpresigned_postfunctions were hardcoded to default tofalse:Solution
Modified both functions to use config values as defaults while still allowing explicit options to override them:
Changes
presigned_url/5: Now readsvirtual_hostandbucket_as_hostfrom config as defaultspresigned_post/4: Now readsvirtual_hostandbucket_as_hostfrom config as defaultsTesting
bucket_as_host=trueRelated
bucket_as_host#306This fix ensures that presigned URLs work correctly with custom domain buckets when
bucket_as_host=trueis set in the ExAws configuration.