Listing Attachments from Current Space
Scenario
The Attachments macro only extracts attachment information from the current Confluence space. This recipe shows how to report on all attachments within the current space. The results are displayed in a table sorted by file size in descending order.
Result
Â
Recipe
Apps |  Reporting for Confluence Server  |
---|---|
Level | Easy |
Estimated time | 15 minutes |
Macros | Content Reporter, Number Sort, Report Column, Report Empty, Report Info, Report Table, Text Filter |
Suppliers | Attachment Supplier, Content Supplier |
Storage format
You can copy and paste this code into the Confluence Source Editor:
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="83840411-f9da-4543-ad66-77590b294fd7" ac:name="report-table" ac:schema-version="1">
<ac:rich-text-body>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="429daffa-887d-4c7d-9f05-470bf7a086f6" ac:name="content-reporter" ac:schema-version="1">
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="85028820-c4ec-400c-83da-93988835bf4e" ac:name="number-sort" ac:schema-version="1">
<ac:parameter ac:name="order">descending</ac:parameter>
<ac:parameter ac:name="">content:file size</ac:parameter>
</ac:structured-macro> <ac:structured-macro ac:macro-id="bf69ab08-1881-4cbf-9fd7-8e570423affb" ac:name="text-filter" ac:schema-version="1">
<ac:parameter ac:name="required">true</ac:parameter>
<ac:parameter ac:name="">attachment:title</ac:parameter>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="b5ac703f-70ee-40ca-8327-da40a0e66b42" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">File Name</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="227634ea-eb68-40bd-a260-be908014d90c" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="link">true</ac:parameter>
<ac:parameter ac:name="">attachment:title</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="e98e2001-74ce-4213-9836-84a03dd88f6c" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Page</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="76925459-4778-45e5-929e-1db9e6b2ca57" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="link">true</ac:parameter>
<ac:parameter ac:name="">attachment:attached to</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="d61dd4fe-586f-44ba-97b0-91b0709c5176" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Size</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="77e19399-5404-4eb6-a6bf-494120e2733d" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">attachment:nice file size</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="c5da15a4-9529-46f4-a7b8-7212815e1520" ac:name="report-empty" ac:schema-version="1">
<ac:rich-text-body>
<p>
<em>No files have been attached to this space.</em>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
Â
Macro structure
You can recreate the example in the editor view:
Steps
Create a Report Table macro.
Within the Report Table macro, create a Content Reporter macro.
Within the Content Reporter, create a Number Sort macro.
Specify the following parameters:Key:Â
content:file size
Order:Â
descending
Still, within the Content Reporter, create a Text Filter macro.
Specify the following parameters:Key:Â
attachment:title
Required:
true
Within the Report Table, create a Report Column macro.
Set the Title to "File Name".Within the Report Column macro, create a Report Info macro.
Specify the following parameters:Key:Â
attachment:title
Link to Item:Â
true
Within the Report Table, create another Report Column macro.
Set the Title to "Page".Within the Report Column macro, create a Report Info macro.
Specify the following parameters:Key:Â
attachment:attached to
Link to Item:Â
true
Within the Report Table, create another Report Column macro.
Set the Title to "Size".Within the Report Column macro, create a Report Info macro.
Specify the following parameters:Key:Â
attachment:nice file size
Within the Report Table macro, create a Report Empty macro.