@@ -2848,29 +2848,30 @@ async def files_upload(
28482848 "You cannot specify both the file and the content argument."
28492849 )
28502850
2851- if file :
2852- if "filename" not in kwargs and isinstance (file , str ):
2853- # use the local filename if filename is missing
2854- kwargs ["filename" ] = file .split (os .path .sep )[- 1 ]
2855- return await self .api_call (
2856- "files.upload" , files = {"file" : file }, data = kwargs
2857- )
2858- data = kwargs .copy ()
2859- data .update (
2851+ if isinstance (channels , (list , Tuple )):
2852+ kwargs .update ({"channels" : "," .join (channels )})
2853+ else :
2854+ kwargs .update ({"channels" : channels })
2855+ kwargs .update (
28602856 {
2861- "content" : content ,
28622857 "filename" : filename ,
28632858 "filetype" : filetype ,
28642859 "initial_comment" : initial_comment ,
28652860 "thread_ts" : thread_ts ,
28662861 "title" : title ,
28672862 }
28682863 )
2869- if isinstance (channels , (list , Tuple )):
2870- kwargs .update ({"channels" : "," .join (channels )})
2864+ if file :
2865+ if "filename" not in kwargs and isinstance (file , str ):
2866+ # use the local filename if filename is missing
2867+ if kwargs .get ("filename" ) is None :
2868+ kwargs ["filename" ] = file .split (os .path .sep )[- 1 ]
2869+ return await self .api_call (
2870+ "files.upload" , files = {"file" : file }, data = kwargs
2871+ )
28712872 else :
2872- kwargs . update ({ "channels" : channels })
2873- return await self .api_call ("files.upload" , data = data )
2873+ kwargs [ "content" ] = content
2874+ return await self .api_call ("files.upload" , data = kwargs )
28742875
28752876 # --------------------------
28762877 # Deprecated: groups.*
0 commit comments