mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Stream in http downloader
This commit is contained in:
parent
4ef0ffe3bf
commit
d18b48aaf4
@ -39,9 +39,10 @@ class HttpDownloader():
|
|||||||
)
|
)
|
||||||
return session
|
return session
|
||||||
|
|
||||||
def download(self, url: str, target_path: Path, parameters: Dict[str, Any] = {}) -> None:
|
def download(self, url: str, target_path: Path, parameters: Optional[Dict[str, Any]] = None) -> None:
|
||||||
"""Download a given url to a given path, optionally with some get parameters."""
|
"""Download a given url to a given path, optionally with some get parameters."""
|
||||||
with self._session.get(url, params=parameters) as response:
|
parameters = parameters if parameters else {}
|
||||||
|
with self._session.get(url, params=parameters, stream=True) as response:
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
tmp_file = self._tmp_dir.new_file()
|
tmp_file = self._tmp_dir.new_file()
|
||||||
stream_to_path(response, tmp_file)
|
stream_to_path(response, tmp_file)
|
||||||
|
Loading…
Reference in New Issue
Block a user