@@ -95,13 +95,16 @@ def upload(
9595 raise ValueError ("Invalid upload options" )
9696 if isinstance (file , str ) or isinstance (file , bytes ):
9797 files .update ({"file" : (None , file )})
98+ if 'overwriteAiTags' in options :
99+ options ['overwriteAITags' ] = options ['overwriteAiTags' ]
100+ del options ['overwriteAiTags' ]
98101 all_fields = {** files , ** options }
99102 multipart_data = MultipartEncoder (
100103 fields = all_fields , boundary = "--randomBoundary---------------------"
101104 )
102105 headers .update ({"Content-Type" : multipart_data .content_type })
103106 resp = self .request .request (
104- "Post" , url = url , data = multipart_data , headers = headers
107+ "Post" , url = url , data = multipart_data . read () , headers = headers
105108 )
106109 if resp .status_code == 200 :
107110 response = convert_to_response_object (resp , UploadFileResult )
@@ -115,6 +118,10 @@ def list(self, options: ListAndSearchFileRequestOptions = None) -> ListFileResul
115118 :return: ListFileResult
116119 """
117120 if options is not None :
121+ if 'tags' in options .__dict__ and isinstance (options .tags , list ):
122+ val = ", " .join (options .tags )
123+ if val :
124+ options .tags = val
118125 formatted_options = request_formatter (options .__dict__ )
119126 if not self .is_valid_list_options (formatted_options ):
120127 raise ValueError ("Invalid option for list_files" )
@@ -215,8 +222,15 @@ def update_file_details(
215222 url = "{}/v1/files/{}/details/" .format (URL .API_BASE_URL , file_id )
216223 headers = {"Content-Type" : "application/json" }
217224 headers .update (self .request .get_auth_headers ())
225+ formatted_options = request_formatter (options .__dict__ )
226+ if 'removeAiTags' in formatted_options :
227+ remove_ai_tags_dict = {'removeAITags' : formatted_options ['removeAiTags' ]}
228+ del formatted_options ['removeAiTags' ]
229+ request_data = {** remove_ai_tags_dict , ** formatted_options }
230+ else :
231+ request_data = formatted_options
218232 data = (
219- dumps (request_formatter ( options . __dict__ ) )
233+ dumps (request_data )
220234 if options is not None
221235 else dict ()
222236 )
@@ -250,15 +264,15 @@ def manage_tags(self, file_ids, tags, action) -> TagsResult:
250264 else :
251265 general_api_throw_exception (resp )
252266
253- def remove_ai_tags (self , file_ids , a_i_tags ) -> TagsResult :
267+ def remove_ai_tags (self , file_ids , ai_tags ) -> TagsResult :
254268 """Remove AI tags of files
255269 :param file_ids: array of file ids
256- :param a_i_tags : array of AI tags
270+ :param ai_tags : array of AI tags
257271 """
258272 url = "{}/v1/files/removeAITags" .format (URL .API_BASE_URL )
259273 headers = {"Content-Type" : "application/json" }
260274 headers .update (self .request .get_auth_headers ())
261- data = dumps ({"fileIds" : file_ids , "AITags" : a_i_tags })
275+ data = dumps ({"fileIds" : file_ids , "AITags" : ai_tags })
262276 resp = self .request .request (method = "Post" , url = url , headers = headers , data = data )
263277 if resp .status_code == 200 :
264278 response = convert_to_response_object (resp , TagsResult )
0 commit comments