package downloader

Import Path
	github.com/gotd/td/telegram/downloader (on go.dev)

Dependency Relation
	imports 22 packages, and imported by one package


Package-Level Type Names (total 19, in which 8 are exported)
/* sort exporteds by: | */
Builder is a download builder. Parallel downloads file to given io.WriterAt. Stream downloads file to given io.Writer. NB: in this mode download can't be parallel. ToPath downloads file to given path. WithRetryHandler sets callback for transient download errors that are retried internally. Handler can be called concurrently from download workers. WithThreads sets downloading goroutines limit. WithVerify controls global hash verification behavior. `true` enables classic verifier reader (preloads hash queue and validates all chunks, both legacy and CDN). `false` disables classic verifier reader. If not called explicitly: - non-CDN path preserves old behavior (no upfront hash requests); - CDN path enables strict inline CDN verification after redirect. Use WithVerify(true) to force verifier-queue mode on all paths. func (*Builder).WithRetryHandler(handler RetryHandler) *Builder func (*Builder).WithThreads(threads int) *Builder func (*Builder).WithVerify(verify bool) *Builder func (*Downloader).Download(rpc Client, location tg.InputFileLocationClass) *Builder func (*Downloader).Web(rpc Client, location tg.InputWebFileLocationClass) *Builder func github.com/gotd/td/telegram.(*Client).Download(location tg.InputFileLocationClass) *Builder func github.com/gotd/td/telegram.(*Client).DownloadWeb(location tg.InputWebFileLocationClass) *Builder
CDN represents Telegram RPC client to CDN server. ( CDN) UploadGetCDNFile(ctx context.Context, request *tg.UploadGetCDNFileRequest) (tg.UploadCDNFileClass, error) *github.com/gotd/td/tg.Client func CDNProvider.CDN(ctx context.Context, dc int, max int64) (CDN, io.Closer, error)
CDNProvider creates client bound to requested CDN DC. Returned closer is schema-scoped; for shared client-level pool adapters this can be a no-op closer. ( CDNProvider) CDN(ctx context.Context, dc int, max int64) (CDN, io.Closer, error)
Client represents Telegram RPC client. ( Client) UploadGetCDNFileHashes(ctx context.Context, request *tg.UploadGetCDNFileHashesRequest) ([]tg.FileHash, error) ( Client) UploadGetFile(ctx context.Context, request *tg.UploadGetFileRequest) (tg.UploadFileClass, error) ( Client) UploadGetFileHashes(ctx context.Context, request *tg.UploadGetFileHashesRequest) ([]tg.FileHash, error) ( Client) UploadGetWebFile(ctx context.Context, request *tg.UploadGetWebFileRequest) (*tg.UploadWebFile, error) ( Client) UploadReuploadCDNFile(ctx context.Context, request *tg.UploadReuploadCDNFileRequest) ([]tg.FileHash, error) *github.com/gotd/td/tg.Client func (*Downloader).Download(rpc Client, location tg.InputFileLocationClass) *Builder func (*Downloader).Web(rpc Client, location tg.InputWebFileLocationClass) *Builder
Downloader is Telegram file downloader. Download creates Builder for plain downloads. Web creates Builder for web files downloads. WithAllowCDN explicitly enables or disables CDN redirect flow. This flag is explicit: if it is not set, downloader keeps legacy master-DC-only behavior and does not attempt CDN redirect handling. Client integration (`telegram.Client.Downloader`) sets this option from `telegram.Options.AllowCDN`. WithPartSize sets chunk size. Must be divisible by 4KB. See https://core.telegram.org/api/files#downloading-files. WithRetryHandler sets callback for transient download errors that are retried internally by downloader. Handler can be called concurrently from download workers. func NewDownloader() *Downloader func (*Downloader).WithAllowCDN(allow bool) *Downloader func (*Downloader).WithPartSize(partSize int) *Downloader func (*Downloader).WithRetryHandler(handler RetryHandler) *Downloader func github.com/gotd/td/telegram.(*Client).Downloader() *Downloader
RedirectError error is returned when Downloader get CDN redirect. See https://core.telegram.org/constructor/upload.fileCdnRedirect. Redirect *tg.UploadFileCDNRedirect Error implements error interface. *RedirectError : error
RetryEvent describes retried transient downloader error. Attempt is 1-based counter inside current retry loop. Err is the error that triggered retry. Operation identifies retry source.
RetryHandler is called for every downloader error that is retried internally. func (*Builder).WithRetryHandler(handler RetryHandler) *Builder func (*Downloader).WithRetryHandler(handler RetryHandler) *Downloader
Package-Level Functions (total 18, in which 1 is exported)
NewDownloader creates new Downloader.
Package-Level Variables (total 2, in which 1 is exported)
ErrHashMismatch means that download hash verification was failed.
Package-Level Constants (total 15, in which 7 are exported)
const RetryOperationCreateClient = "cdn.create_client"
const RetryOperationGetFile = "cdn.get_file"
const RetryOperationGetFileHashes = "cdn.get_file_hashes"
const RetryOperationRefreshRedirect = "cdn.refresh_redirect"
const RetryOperationReupload = "cdn.reupload"