Skip to content

Commit d1dca54

Browse files
committed
change(files): add requests_kwargs to download_file function
1 parent c28670a commit d1dca54

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

iarp_utils/files.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def generate_file_hash(opened_file, func=hashlib.md5):
4444
return output
4545

4646

47-
def download_file(url: str, path_to_file):
47+
def download_file(url: str, path_to_file, requests_kwargs=None):
4848
""" Download a file from a remote HTTP server.
4949
5050
Examples:
@@ -54,8 +54,11 @@ def download_file(url: str, path_to_file):
5454
Args:
5555
url: URL to the file
5656
path_to_file: filename to save to locally
57+
requests_kwargs:
5758
"""
58-
with requests.get(url, stream=True) as response, open(path_to_file, 'wb') as out_file:
59+
if requests_kwargs is None:
60+
requests_kwargs = {}
61+
with requests.get(url, stream=True, **requests_kwargs) as response, open(path_to_file, 'wb') as out_file:
5962
shutil.copyfileobj(response.raw, out_file)
6063

6164

0 commit comments

Comments
 (0)