@@ -3007,11 +3007,9 @@ async def files_upload_v2(
30073007 title : Optional [str ] = None ,
30083008 alt_txt : Optional [str ] = None ,
30093009 snippet_type : Optional [str ] = None ,
3010- filetype : Optional [str ] = None , # no longer supported
30113010 # To upload multiple files at a time
30123011 upload_files : Optional [List [Dict [str , Any ]]] = None ,
30133012 channel : Optional [str ] = None ,
3014- channels : Optional [Union [str , Sequence [str ]]] = None , # having n channels is no longer supported
30153013 initial_comment : Optional [str ] = None ,
30163014 thread_ts : Optional [str ] = None ,
30173015 ** kwargs ,
@@ -3025,13 +3023,24 @@ async def files_upload_v2(
30253023 raise e .SlackRequestError ("Any of file, content, and upload_files must be specified." )
30263024 if file is not None and content is not None :
30273025 raise e .SlackRequestError ("You cannot specify both the file and the content argument." )
3028- if channels is not None and (
3029- (isinstance (channels , (list , Tuple )) and len (channels ) > 1 )
3030- or (isinstance (channels , str ) and len (channels .split ("," )) > 1 )
3031- ):
3032- raise e .SlackRequestError ("Sharing files with multiple channels is no longer supported" )
3026+
3027+ # deprecated arguments:
3028+ channels , filetype = kwargs .get ("channels" ), kwargs .get ("filetype" )
3029+
3030+ if channels is not None :
3031+ warnings .warn (
3032+ "Although the channels parameter is still supported for smooth migration from legacy files.upload, "
3033+ "we recommend using the new channel parameter with a single str value instead for more clarity."
3034+ )
3035+ if (isinstance (channels , (list , Tuple )) and len (channels ) > 1 ) or (
3036+ isinstance (channels , str ) and len (channels .split ("," )) > 1
3037+ ):
3038+ raise e .SlackRequestError (
3039+ "Sharing files with multiple channels is no longer supported in v2. "
3040+ "Share files in each channel separately instead."
3041+ )
30333042 if filetype is not None :
3034- warnings .warn ("filetype is no longer supported. Please remove it from the arguments." )
3043+ warnings .warn ("The filetype parameter is no longer supported. Please remove it from the arguments." )
30353044
30363045 # step1: files.getUploadURLExternal per file
30373046 files : List [Dict [str , Any ]] = []
@@ -3060,8 +3069,8 @@ async def files_upload_v2(
30603069 token = kwargs .get ("token" ),
30613070 )
30623071 _validate_for_legacy_client (url_response )
3063- f ["file_id" ] = url_response .get ("file_id" )
3064- f ["upload_url" ] = url_response .get ("upload_url" )
3072+ f ["file_id" ] = url_response .get ("file_id" ) # type: ignore
3073+ f ["upload_url" ] = url_response .get ("upload_url" ) # type: ignore
30653074
30663075 # step2: "https://files.slack.com/upload/v1/..." per file
30673076 for f in files :
0 commit comments