Skip to content

Commit

Permalink
AWS_HTTPS support + fix missing scheme (#476)
Browse files Browse the repository at this point in the history
* AWS_HTTPS support + fix missing scheme

* updated changelog

* is not!

* black reformatting

* GDAL bool evaluation

Co-authored-by: Vincent Sarago <[email protected]>

* GDAL options comment

* black reformatting

Co-authored-by: Vincent Sarago <[email protected]>
  • Loading branch information
emmanuelmathot and vincentsarago authored Feb 4, 2022
1 parent e3e147d commit 90e5065
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# unreleased

* add support for setting the S3 endpoint url scheme via the `AWS_HTTPS` environment variables in `aws_get_object` function using boto3 (https://github.com/cogeotiff/rio-tiler/pull/476)

# 3.0.3 (2022-01-18)

Expand Down
8 changes: 8 additions & 0 deletions rio_tiler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ def aws_get_object(
"""AWS s3 get object content."""
if not client:
session = boto3_session()
# AWS_S3_ENDPOINT and AWS_HTTPS are GDAL config options of vsis3 driver
# https://gdal.org/user/virtual_file_systems.html#vsis3-aws-s3-files
endpoint_url = os.environ.get("AWS_S3_ENDPOINT", None)
if endpoint_url is not None:
use_https = os.environ.get("AWS_HTTPS", "YES")
if use_https.upper() in ["YES", "TRUE", "ON"]:
endpoint_url = "https://" + endpoint_url
else:
endpoint_url = "http://" + endpoint_url
client = session.client("s3", endpoint_url=endpoint_url)

params = {"Bucket": bucket, "Key": key}
Expand Down

0 comments on commit 90e5065

Please sign in to comment.