@@ -317,6 +317,31 @@ def from_json(cls, data: JsonResponse) -> "Attachment":
317
317
version = Version .from_json (data .get ("version" , {})),
318
318
)
319
319
320
+ @classmethod
321
+ def from_page_id (cls , page_id : int ) -> list ["Attachment" ]:
322
+ attachments = []
323
+ start = 0
324
+ paging_limit = 50
325
+ size = paging_limit # Initialize to limit to enter the loop
326
+
327
+ while size >= paging_limit :
328
+ response = cast (
329
+ JsonResponse ,
330
+ confluence .get_attachments_from_content (
331
+ page_id ,
332
+ start = start ,
333
+ limit = paging_limit ,
334
+ expand = "container.ancestors,version" ,
335
+ ),
336
+ )
337
+
338
+ attachments .extend ([cls .from_json (att ) for att in response .get ("results" , [])])
339
+
340
+ size = response .get ("size" , 0 )
341
+ start += size
342
+
343
+ return attachments
344
+
320
345
def export (self , export_path : StrPath ) -> None :
321
346
filepath = Path (export_path ) / self .export_path
322
347
if filepath .exists ():
@@ -477,14 +502,6 @@ def get_attachments_by_title(self, title: str) -> list[Attachment]:
477
502
478
503
@classmethod
479
504
def from_json (cls , data : JsonResponse ) -> "Page" :
480
- attachments = cast (
481
- JsonResponse ,
482
- confluence .get_attachments_from_content (
483
- data .get ("id" , 0 ),
484
- limit = 1000 ,
485
- expand = "container.ancestors,version" ,
486
- ),
487
- )
488
505
return cls (
489
506
id = data .get ("id" , 0 ),
490
507
title = data .get ("title" , "" ),
@@ -496,9 +513,7 @@ def from_json(cls, data: JsonResponse) -> "Page":
496
513
Label .from_json (label )
497
514
for label in data .get ("metadata" , {}).get ("labels" , {}).get ("results" , [])
498
515
],
499
- attachments = [
500
- Attachment .from_json (attachment ) for attachment in attachments .get ("results" , [])
501
- ],
516
+ attachments = Attachment .from_page_id (data .get ("id" , 0 )),
502
517
ancestors = [ancestor .get ("id" ) for ancestor in data .get ("ancestors" , [])][1 :],
503
518
)
504
519
0 commit comments