From 483816cc2b9d1cc85fe43f53af78a282bfa8df24 Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Mon, 28 Apr 2025 12:35:47 +0300 Subject: [PATCH] media: Request 1MB chunks for direct media streaming The default is 512kB and the RPC request overhead has more impact on download speed than having half smaller chunks. Next level speed improvement would be to use parallel downloads and have an on-disk buffer to stream out the rebuilt file on-the-fly when we consistent stream of data available. --- pkg/connector/media/transfer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/connector/media/transfer.go b/pkg/connector/media/transfer.go index 06cf5df0..40d37fb1 100644 --- a/pkg/connector/media/transfer.go +++ b/pkg/connector/media/transfer.go @@ -333,7 +333,7 @@ func (t *ReadyTransferer) Transfer(ctx context.Context, store *store.Container, // Stream streams the media from Telegram to an [io.Reader]. func (t *ReadyTransferer) Stream(ctx context.Context) (r io.Reader, mimeType string, fileSize int, err error) { var storageFileTypeClass tg.StorageFileTypeClass - storageFileTypeClass, r, err = downloader.NewDownloader().Download(t.inner.client, t.loc).StreamToReader(ctx) + storageFileTypeClass, r, err = downloader.NewDownloader().WithPartSize(1024*1024).Download(t.inner.client, t.loc).StreamToReader(ctx) if err != nil { return nil, "", 0, err }