Get Attachment from multiple pages and add it to one page

Hi everyone, i’m searching for a velocity function to add an attachment to a page.

#macro(changeAttachements $sectionChildDocument)
     #set($list=$sectionChildDocument.getAttachmentList())
     #foreach($attachment in $list)
       ##$doc.addAttachments()
     #end
 #end

The addAttachment() function neads the name of the attachment but the getAttachmentList() returns a list of types “Attachments”. So i want to know if it exist an addAttachment() function where i can pass an Attachment as parameter.

Hi, see Scripting API Guide (XWiki.org)

Thanks

You can check all the addAttachment methods in xwiki-platform/Document.java at 360f07f98c17c80e7324ff2bbefbf757e4fe1376 · xwiki/xwiki-platform · GitHub

The Attachment object is xwiki-platform/Attachment.java at 262e5867460f97549699f9fd8df35d92887e5c40 · xwiki/xwiki-platform · GitHub and you can get from it the filename and the input stream.

Thanks, i’ll try other methods !