connection#

Classes#

DirectDownloadAdapter

Protocol for adapters that support optimized direct-to-file downloads.

class DirectDownloadAdapter#

Bases: Protocol

Protocol for adapters that support optimized direct-to-file downloads.

Adapters implementing this protocol can bypass the standard streaming path and write directly to a file object, avoiding intermediate buffering.

direct_download(url: str, fileobj: IO[bytes], progress_callback: collections.abc.Callable[[float], None] | None = None, size: int | None = None) None#

Download directly to a file object.

Parameters:
  • url -- URL to download from

  • fileobj -- File object to write to (binary write mode)

  • progress_callback -- Optional callback(fraction) where fraction is 0.0-1.0

  • size -- Content length (required for progress reporting)