From 5362c5667f185a8e51038af701f6d86855273b38 Mon Sep 17 00:00:00 2001 From: Emmanuel Mathot Date: Thu, 27 May 2021 12:05:28 +0200 Subject: [PATCH 1/3] AWS_S3_ENDPOINT in aws_get_object --- rio_tiler/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rio_tiler/utils.py b/rio_tiler/utils.py index 7379dab9..b62b0bf6 100644 --- a/rio_tiler/utils.py +++ b/rio_tiler/utils.py @@ -1,6 +1,7 @@ """rio_tiler.utils: utility functions.""" from io import BytesIO +import os from typing import Any, Dict, Generator, Optional, Sequence, Tuple, Union import numpy @@ -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: From 95c5c3e92627de842882ac60b190b219349da85e Mon Sep 17 00:00:00 2001 From: Emmanuel Mathot Date: Thu, 27 May 2021 12:13:44 +0200 Subject: [PATCH 2/3] updated changelog --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) 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) From 238ea51412ab2096826de28d2e539937e2ffd8f5 Mon Sep 17 00:00:00 2001 From: Emmanuel Mathot Date: Thu, 27 May 2021 12:22:00 +0200 Subject: [PATCH 3/3] linting --- rio_tiler/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rio_tiler/utils.py b/rio_tiler/utils.py index b62b0bf6..c305b3f4 100644 --- a/rio_tiler/utils.py +++ b/rio_tiler/utils.py @@ -1,7 +1,7 @@ """rio_tiler.utils: utility functions.""" -from io import BytesIO import os +from io import BytesIO from typing import Any, Dict, Generator, Optional, Sequence, Tuple, Union import numpy @@ -37,7 +37,7 @@ def aws_get_object( """AWS s3 get object content.""" if not client: session = boto3_session() - endpoint_url = os.environ.get('AWS_S3_ENDPOINT', None) + endpoint_url = os.environ.get("AWS_S3_ENDPOINT", None) client = session.client("s3", endpoint_url=endpoint_url) params = {"Bucket": bucket, "Key": key}