import requests
import shutil


def _download_file(url, target_path, timeout=10):
    """Download a file and save it to a folder"""
    with requests.get(url, stream=True, timeout=timeout) as response:
        response.raise_for_status()
        response.raw.decode_content = True
        with open(target_path, 'wb') as dst:
            shutil.copyfileobj(response.raw, dst)

    return target_path