From caa26b2c6a83363c9329e49be1fa77352bcef461 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 20 Jun 2022 10:32:17 +0200 Subject: [PATCH] Improve upload file size checks --- pyrogram/methods/advanced/save_file.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyrogram/methods/advanced/save_file.py b/pyrogram/methods/advanced/save_file.py index 706f28e0..6a43deac 100644 --- a/pyrogram/methods/advanced/save_file.py +++ b/pyrogram/methods/advanced/save_file.py @@ -125,8 +125,10 @@ class SaveFile: if file_size == 0: raise ValueError("File size equals to 0 B") - if file_size > 2000 * 1024 * 1024: - raise ValueError("Telegram doesn't support uploading files bigger than 2000 MiB") + file_size_limit_mib = 4000 if self.me.is_premium else 2000 + + if file_size > file_size_limit_mib * 1024 * 1024: + raise ValueError(f"Can't upload files bigger than {file_size_limit_mib} MiB") file_total_parts = int(math.ceil(file_size / part_size)) is_big = file_size > 10 * 1024 * 1024