@@ -1400,14 +1400,14 @@ def attach_file(
14001400 comment = comment ,
14011401 )
14021402
1403- def download_attachments_from_page (self , page_id , save_path = None , start = 0 , limit = 50 , filename = None , to_memory = False ):
1403+ def download_attachments_from_page (self , page_id , path = None , start = 0 , limit = 50 , filename = None , to_memory = False ):
14041404 """
14051405 Downloads attachments from a Confluence page. Supports downloading all files or a specific file.
14061406 Files can either be saved to disk or returned as BytesIO objects for in-memory handling.
14071407
14081408 :param page_id: str
14091409 The ID of the Confluence page to fetch attachments from.
1410- :param save_path : str, optional
1410+ :param path : str, optional
14111411 Directory where attachments will be saved. If None, defaults to the current working directory.
14121412 Ignored if `to_memory` is True.
14131413 :param start: int, optional
@@ -1423,14 +1423,14 @@ def download_attachments_from_page(self, page_id, save_path=None, start=0, limit
14231423 - If `to_memory` is True, returns a dictionary {filename: BytesIO object}.
14241424 - If `to_memory` is False, returns a summary dict: {"attachments_downloaded": int, "path": str}.
14251425 :raises:
1426- - FileNotFoundError: If the specified save_path does not exist.
1427- - PermissionError: If there are permission issues with the specified save_path .
1426+ - FileNotFoundError: If the specified path does not exist.
1427+ - PermissionError: If there are permission issues with the specified path .
14281428 - requests.HTTPError: If the HTTP request to fetch an attachment fails.
14291429 - Exception: For any unexpected errors.
14301430 """
1431- # Default save_path to current working directory if not provided
1432- if not to_memory and save_path is None :
1433- save_path = os .getcwd ()
1431+ # Default path to current working directory if not provided
1432+ if not to_memory and path is None :
1433+ path = os .getcwd ()
14341434
14351435 try :
14361436 # Fetch attachments based on the specified parameters
@@ -1461,20 +1461,20 @@ def download_attachments_from_page(self, page_id, save_path=None, start=0, limit
14611461 downloaded_files [file_name ] = file_obj
14621462 else :
14631463 # Save file to disk
1464- file_path = os .path .join (save_path , file_name )
1464+ file_path = os .path .join (path , file_name )
14651465 with open (file_path , "wb" ) as file :
14661466 file .write (response .content )
14671467
14681468 # Return results based on storage mode
14691469 if to_memory :
14701470 return downloaded_files
14711471 else :
1472- return {"attachments_downloaded" : len (attachments ), "path" : save_path }
1472+ return {"attachments_downloaded" : len (attachments ), "path" : path }
14731473
14741474 except NotADirectoryError :
1475- raise FileNotFoundError (f"The directory '{ save_path } ' does not exist." )
1475+ raise FileNotFoundError (f"The directory '{ path } ' does not exist." )
14761476 except PermissionError :
1477- raise PermissionError (f"Permission denied when trying to save files to '{ save_path } '." )
1477+ raise PermissionError (f"Permission denied when trying to save files to '{ path } '." )
14781478 except requests .HTTPError as http_err :
14791479 raise Exception (f"HTTP error occurred while downloading attachments: { http_err } " )
14801480 except Exception as err :
0 commit comments