diff --git a/openeo/rest/connection.py b/openeo/rest/connection.py index 28de15dfd..8b4663a3b 100644 --- a/openeo/rest/connection.py +++ b/openeo/rest/connection.py @@ -83,6 +83,7 @@ ContextTimer, LazyLoadCache, dict_no_none, + ensure_dir, ensure_list, load_json_resource, repr_truncate, @@ -1748,7 +1749,9 @@ def download( ) if outputfile is not None: - with Path(outputfile).open(mode="wb") as f: + target = Path(outputfile) + ensure_dir(target.parent) + with target.open(mode="wb") as f: for chunk in response.iter_content(chunk_size=chunk_size): f.write(chunk) else: