Added support for path style in presigned Post #2835
Closed
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.
Following #2827
toBaseURL
adds support for the following casing:Checks if the input URL has a leading slash by inspecting the path segments. If so, it removes the leading empty segment.
Determines if the URL is "path-style" (bucket name in path) or "virtual-hosted" (bucket name in host) by checking the length of the path segments. If there are multiple segments, it's path-style; otherwise, it's virtual-hosted. The function then constructs the appropriate base URL accordingly.
This is a heuristic approach of parsing the URL and will not cover all of the edge cases and ways for users of the SDK to provide an custom endpoint that might not work accordingly.
To solve this, I added a
PresignPostOptions
option calledBaseURLOverride
which will let users directly override the URL that the presigner uses.Added test cases for both additions.