@@ -1400,14 +1400,14 @@ def attach_file(
1400
1400
comment = comment ,
1401
1401
)
1402
1402
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 ):
1404
1404
"""
1405
1405
Downloads attachments from a Confluence page. Supports downloading all files or a specific file.
1406
1406
Files can either be saved to disk or returned as BytesIO objects for in-memory handling.
1407
1407
1408
1408
:param page_id: str
1409
1409
The ID of the Confluence page to fetch attachments from.
1410
- :param save_path : str, optional
1410
+ :param path : str, optional
1411
1411
Directory where attachments will be saved. If None, defaults to the current working directory.
1412
1412
Ignored if `to_memory` is True.
1413
1413
:param start: int, optional
@@ -1423,14 +1423,14 @@ def download_attachments_from_page(self, page_id, save_path=None, start=0, limit
1423
1423
- If `to_memory` is True, returns a dictionary {filename: BytesIO object}.
1424
1424
- If `to_memory` is False, returns a summary dict: {"attachments_downloaded": int, "path": str}.
1425
1425
: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 .
1428
1428
- requests.HTTPError: If the HTTP request to fetch an attachment fails.
1429
1429
- Exception: For any unexpected errors.
1430
1430
"""
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 ()
1434
1434
1435
1435
try :
1436
1436
# 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
1461
1461
downloaded_files [file_name ] = file_obj
1462
1462
else :
1463
1463
# Save file to disk
1464
- file_path = os .path .join (save_path , file_name )
1464
+ file_path = os .path .join (path , file_name )
1465
1465
with open (file_path , "wb" ) as file :
1466
1466
file .write (response .content )
1467
1467
1468
1468
# Return results based on storage mode
1469
1469
if to_memory :
1470
1470
return downloaded_files
1471
1471
else :
1472
- return {"attachments_downloaded" : len (attachments ), "path" : save_path }
1472
+ return {"attachments_downloaded" : len (attachments ), "path" : path }
1473
1473
1474
1474
except NotADirectoryError :
1475
- raise FileNotFoundError (f"The directory '{ save_path } ' does not exist." )
1475
+ raise FileNotFoundError (f"The directory '{ path } ' does not exist." )
1476
1476
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 } '." )
1478
1478
except requests .HTTPError as http_err :
1479
1479
raise Exception (f"HTTP error occurred while downloading attachments: { http_err } " )
1480
1480
except Exception as err :
0 commit comments