diff --git a/CHANGES.md b/CHANGES.md index 20875d05..19f79cc4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,6 @@ +## Unreleased +* add support for setting the S3 endpoint url via the `AWS_S3_ENDPOINT` environment variables in `aws_get_object` function using boto3 (https://github.com/cogeotiff/rio-tiler/pull/394) ## 2.1.0 (2021-05-17) * add auto-rescaling in `ImageData.render` method to avoid error when datatype is not supported by the output driver (https://github.com/cogeotiff/rio-tiler/pull/391) diff --git a/rio_tiler/utils.py b/rio_tiler/utils.py index 7379dab9..c305b3f4 100644 --- a/rio_tiler/utils.py +++ b/rio_tiler/utils.py @@ -1,5 +1,6 @@ """rio_tiler.utils: utility functions.""" +import os from io import BytesIO from typing import Any, Dict, Generator, Optional, Sequence, Tuple, Union @@ -36,7 +37,8 @@ def aws_get_object( """AWS s3 get object content.""" if not client: session = boto3_session() - client = session.client("s3") + endpoint_url = os.environ.get("AWS_S3_ENDPOINT", None) + client = session.client("s3", endpoint_url=endpoint_url) params = {"Bucket": bucket, "Key": key} if request_pays: