@@ -1974,10 +1974,15 @@ def send_chat_action(self,
19741974 Raises:
19751975 :class:`pyrogram.Error`
19761976 """
1977+ if "Upload" in action .__name__ :
1978+ action = action (progress )
1979+ else :
1980+ action = action ()
1981+
19771982 return self .send (
19781983 functions .messages .SetTyping (
19791984 peer = self .resolve_peer (chat_id ),
1980- action = action ( progress = progress )
1985+ action = action
19811986 )
19821987 )
19831988
@@ -2171,14 +2176,21 @@ def save_file(self,
21712176 md5_sum = "" .join ([hex (i )[2 :].zfill (2 ) for i in md5_sum .digest ()])
21722177 break
21732178
2174- session . send (
2175- ( functions . upload . SaveBigFilePart if is_big else functions .upload .SaveFilePart ) (
2179+ if is_big :
2180+ rpc = functions .upload .SaveBigFilePart (
21762181 file_id = file_id ,
21772182 file_part = file_part ,
2178- bytes = chunk ,
2179- file_total_parts = file_total_parts
2183+ file_total_parts = file_total_parts ,
2184+ bytes = chunk
2185+ )
2186+ else :
2187+ rpc = functions .upload .SaveFilePart (
2188+ file_id = file_id ,
2189+ file_part = file_part ,
2190+ bytes = chunk
21802191 )
2181- )
2192+
2193+ assert self .send (rpc ), "Couldn't upload file"
21822194
21832195 if is_missing_part :
21842196 return
@@ -2191,14 +2203,22 @@ def save_file(self,
21912203 if progress :
21922204 progress (min (file_part * part_size , file_size ), file_size )
21932205 except Exception as e :
2194- log .error (e )
2206+ log .error (e , exc_info = True )
21952207 else :
2196- return (types .InputFileBig if is_big else types .InputFile )(
2197- id = file_id ,
2198- parts = file_total_parts ,
2199- name = os .path .basename (path ),
2200- md5_checksum = md5_sum
2201- )
2208+ if is_big :
2209+ return types .InputFileBig (
2210+ id = file_id ,
2211+ parts = file_total_parts ,
2212+ name = os .path .basename (path ),
2213+
2214+ )
2215+ else :
2216+ return types .InputFile (
2217+ id = file_id ,
2218+ parts = file_total_parts ,
2219+ name = os .path .basename (path ),
2220+ md5_checksum = md5_sum
2221+ )
22022222 finally :
22032223 session .stop ()
22042224
@@ -2318,7 +2338,6 @@ def get_file(self,
23182338 while True :
23192339 r2 = cdn_session .send (
23202340 functions .upload .GetCdnFile (
2321- location = location ,
23222341 file_token = r .file_token ,
23232342 offset = offset ,
23242343 limit = limit
0 commit comments