-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
S3 has two endpoints, a “path-based” endpoint and “virtual-hosted-style” endpoints. ([read more](https://medium.com/@e.osama85/the-difference-between-the-amazon-s3-path-style-urls-and-virtual-hosted-style-urls-4fafd5eca4db)) Virtual hosted style uses a different hostname for each bucket, while path-style uses one endpoint and puts the bucket name in the path. Path-style is easier to set up when using an S3-compatible API like minio, because you don't have to deal with DNS certs etc. Previously, we only used path-style if the URL was set to `localhost`, which was basically only useful for our tests that ran `minio` locally. This change allows the use of path-style URLs by setting the `AWS_S3_USE_PATH_STYLE` env variable. It also supports the old `localhost` behavior, but warns and suggests using `AWS_S3_USE_PATH_STYLE`. ## `bucket_prefix` bug fix This also fixes a bug where `Some("")` was being used as a `bucket_prefix`. When a bucket prefix is a `Some`, we prepend it to the path separated by "/", as in "{bucket_prefix}/{path}". With an empty `bucket_prefix`, the resulting path is an "absolute-path" (since it begins with a slash) instead of a "relative path" as the rest of the code expects. In particular, `Url::join` behaves very differently when passed an "absolute path" than a relative one: with an absolute path, the new path _replaces_ the whole other old one. So what was happening was that when we had a `bucket_prefix` of `/`, if the bucket name was in the path (as in path-style URLs), the bucket name was inadvertently removed from the path. The fix is as simple as ensuring that `Some("")` is converted to `None`, as in: ```rust let bucket_prefix = (!bucket_prefix.is_empty()).then(|| bucket_prefix); ```
- Loading branch information
Showing
4 changed files
with
42 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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