From 5be3dba972ff557dc7613c4fb4dc8eda1940e467 Mon Sep 17 00:00:00 2001 From: "Mr. Mahdi" Date: Wed, 10 Jul 2024 04:57:04 +0300 Subject: [PATCH 1/3] Update methods.py --- tgram/methods.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tgram/methods.py b/tgram/methods.py index f749392..86f413e 100644 --- a/tgram/methods.py +++ b/tgram/methods.py @@ -926,7 +926,7 @@ async def download_file( async with session.request("GET", url=url) as response: if response.status != 200: raise APIException("Download file", response) - result = await response.read() + result = await response.read() if in_memory: memory_file = io.BytesIO() memory_file.write(result) @@ -934,9 +934,9 @@ async def download_file( memory_file.name = file_path return memory_file else: - with open(Path(file_path), "wb") as f: + with open(Path(file_path.split('/')[1]), "wb") as f: f.write(result) - return Path(file_path) + return Path(file_path.split('/')[1]) async def get_file_url(self: "tgram.TgBot", file_id: str) -> str: file = await self.get_file(file_id) From dc89313135e88255ba5eda1fbecf119641095df0 Mon Sep 17 00:00:00 2001 From: "Mr. Mahdi" Date: Wed, 10 Jul 2024 05:08:24 +0300 Subject: [PATCH 2/3] updating --- tgram/methods.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tgram/methods.py b/tgram/methods.py index 86f413e..eddc30e 100644 --- a/tgram/methods.py +++ b/tgram/methods.py @@ -920,7 +920,7 @@ async def download_file( self: "tgram.TgBot", file_id: str, file_path: str = None, in_memory: bool = None ) -> Union[Path, io.BytesIO]: file = await self.get_file(file_id) - file_path = file_path or file.file_path + file_path = file_path or file.file_path.split('/')[1] url = self.api_url + f"file/bot{self.bot_token}/{file.file_path}" session = await self._get_session() async with session.request("GET", url=url) as response: @@ -934,9 +934,9 @@ async def download_file( memory_file.name = file_path return memory_file else: - with open(Path(file_path.split('/')[1]), "wb") as f: + with open(Path(file_path), "wb") as f: f.write(result) - return Path(file_path.split('/')[1]) + return Path(file_path) async def get_file_url(self: "tgram.TgBot", file_id: str) -> str: file = await self.get_file(file_id) From b270afeb7cb4bfeb59a98910c7daafcc6913c9bc Mon Sep 17 00:00:00 2001 From: Zaid Date: Wed, 10 Jul 2024 05:18:13 +0300 Subject: [PATCH 3/3] reformat --- tgram/methods.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgram/methods.py b/tgram/methods.py index eddc30e..4330083 100644 --- a/tgram/methods.py +++ b/tgram/methods.py @@ -920,7 +920,7 @@ async def download_file( self: "tgram.TgBot", file_id: str, file_path: str = None, in_memory: bool = None ) -> Union[Path, io.BytesIO]: file = await self.get_file(file_id) - file_path = file_path or file.file_path.split('/')[1] + file_path = file_path or file.file_path.split("/")[1] url = self.api_url + f"file/bot{self.bot_token}/{file.file_path}" session = await self._get_session() async with session.request("GET", url=url) as response: