Files
fn_registry/python/functions/infra/http_download_file.md
T
egutierrez 5a324f6554 feat: funciones Python infra y tipos Python (core, datascience, infra)
Infra: cache_to_file, cache_to_sqlite, http_download_file, http_get_json,
http_post_json, read_file_with_encoding, safe_extract_zip, scan_directory,
setup_logger, normalize_zip_filenames.
Tipos: 30+ tipos core (agent_action, context, task, message, parse_result...),
6 tipos datascience (entity_candidate, extraction_result...), 2 tipos infra.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 17:11:43 +02:00

1.5 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports tested tests test_file_path file_path
http_download_file function py infra 1.0.0 impure http_download_file(url: str, dest_path: str, headers: dict[str, str] | None = None, timeout: float = 120.0, chunk_size: int = 8192) -> dict Descarga un archivo por HTTP en streaming (sin cargar todo en memoria). Crea directorios intermedios si no existen. Retorna dict con path, size_bytes y content_type.
http
download
file
streaming
network
stdlib
infra
false error_go_core
os
urllib.error
urllib.request
true
mock de descarga con contenido binario
directorio destino creado automaticamente
retorno con size correcto
timeout configurado en el request
python/functions/infra/http_download_file_test.py python/functions/infra/http_download_file.py

Ejemplo

result = http_download_file(
    "https://example.com/report.pdf",
    dest_path="/tmp/reports/report.pdf",
    timeout=60.0,
)
print(f"Downloaded {result['size_bytes']} bytes to {result['path']}")

Notas

Solo usa stdlib (urllib, os). La descarga se hace en chunks de chunk_size bytes para evitar consumo de memoria con archivos grandes. El timeout de 120s por defecto es mayor que http_get_json porque los archivos pueden ser pesados. Los directorios intermedios se crean con os.makedirs(exist_ok=True).