Skip to content

miniproto.media.cdn.get_cdn_file_part

get_cdn_file_part(invoke: RawInvoker, redirect: CdnRedirect, *, offset: int, limit: int, request_timeout: float | None = None) -> bytes

Fetch, decrypt, and hash-verify one CDN file range.

Parameters:

  • invoke (RawInvoker) – Async raw-RPC invoker bound to the appropriate data center.
  • redirect (CdnRedirect) – CDN credentials and encryption metadata returned by Telegram.
  • offset (int) – Byte offset of the requested range and CTR stream.
  • limit (int) – Maximum ciphertext/plaintext bytes to retrieve.
  • request_timeout (float | None) – Optional per-RPC timeout in seconds.

Returns:

  • bytes – The decrypted, integrity-verified bytes returned for the requested range.

Raises:

  • CdnIntegrityError – The range lacks coverage, has an invalid/short declared hash range, or its digest mismatches.
  • CdnError – Telegram returns an unsupported CDN response.
  • CancelledError – The caller cancels the awaited transfer.