Documentation - v0.30.3
    Preparing search index...

    Interface FileDownloadParameters

    interface FileDownloadParameters {
        abortSignal?: AbortSignal;
        dcId?: number;
        fileSize?: number;
        limit?: number;
        offset?: number;
        partSize?: number;
        progressCallback?: (downloaded: number, total: number) => void;
        stallTimeout?: number;
    }
    Index

    Properties

    abortSignal?: AbortSignal

    Abort signal that can be used to cancel the download.

    dcId?: number

    DC id from which the file will be downloaded.

    If provided DC is not the one storing the file, redirection will be handled automatically.

    fileSize?: number

    Total file size, if known. Used to determine upload part size. In some cases can be inferred from file automatically.

    limit?: number

    Number of bytes to be downloaded. By default, downloads the entire file

    offset?: number

    Offset in bytes. Must be divisible by 4096 (4 KB).

    partSize?: number

    Download part size (in KB). By default, automatically selected depending on the file size (or 64, if not provided). Must not be bigger than 512, must not be a fraction, and must be divisible by 4.

    progressCallback?: (downloaded: number, total: number) => void

    Function that will be called after some part has been downloaded.

    Type Declaration

      • (downloaded: number, total: number): void
      • Parameters

        • downloaded: number
        • total: number

          Total file size (Infinity if not available)

        Returns void

    stallTimeout?: number

    If set, the download will be aborted (and an MtTimeoutError will be thrown) if no new chunk has been received within this amount of time (in milliseconds).

    Useful for bulk downloads where some files might be unavailable server-side (and would otherwise cause the download to hang indefinitely due to the server repeatedly responding with FLOOD_WAIT or -503 Timeout).