Skip to content

Commit

Permalink
Pass auth headers to lizard, but not to S3
Browse files Browse the repository at this point in the history
  • Loading branch information
reinout committed Jan 26, 2024
1 parent ac7c3ad commit f9866cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Changelog of threedi-scenario-downloader
- Improved test setup: a pytest fixture automatically sets up the api
key. Add one to ``test_api_key.txt``.

- When downloading files from amazon S3, we don't send along lizard authentication headers.


1.3 (2024-01-17)
----------------
Expand Down
6 changes: 5 additions & 1 deletion threedi_scenario_downloader/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@ def get_task_download_url(task_uuid):
def download_file(url, path):
"""download url to specified path"""
logger.debug(f"Start downloading file: {url}")
r = requests.get(url, stream=True)
if "amazon" not in url:
r = requests.get(url, auth=("__key__", get_api_key()), stream=True)
else:
# Amazon s3 request: don't send lizard's auth headers.
r = requests.get(url, stream=True)
r.raise_for_status()
with open(path, "wb") as file:
for chunk in r.iter_content(1024 * 1024 * 10):
Expand Down

0 comments on commit f9866cd

Please sign in to comment.