voxcity.downloader.utilsΒΆ

FunctionsΒΆ

download_file(url, filename, *[, timeout, ...])

Download a file from a URL and save it locally with retry and streaming.

Module ContentsΒΆ

voxcity.downloader.utils.download_file(url, filename, *, timeout=60, max_retries=3, initial_delay=2.0, backoff_factor=2.0, chunk_size=8192)[source]ΒΆ

Download a file from a URL and save it locally with retry and streaming.

Uses streaming to avoid loading large files entirely into memory and retries on transient network failures with exponential backoff.

Parameters:
  • url (str) – URL of the file to download.

  • filename (str) – Local path where the downloaded file will be saved.

  • timeout (int) – Request timeout in seconds (default 60).

  • max_retries (int) – Number of retry attempts on failure (default 3).

  • initial_delay (float) – Seconds to wait before the first retry (default 2.0).

  • backoff_factor (float) – Multiplier for delay between retries (default 2.0).

  • chunk_size (int) – Bytes per chunk when streaming (default 8192).

Raises:

requests.HTTPError – If download fails after all retries.

Example

>>> download_file('https://example.com/file.pdf', 'local_file.pdf')