How can I get list of attachments on server sorted by size?

Pavel Potcheptsov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 14, 2019

I use standalone Confluence server on Linux.

Attachment's storage is default on file system.

What I would like to get is a list of files sorted by size from larger to smaller.

I can use linux utils for that by that gives me only size since all files have same "1" name under different paths.

1 answer

0 votes
Dominic Lagger
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 14, 2019

Hi @Pavel Potcheptsov 

On confluence, there is a macro for that: Attachments. 

In this macro, you can show attachments of that page and sort by size. 

There is another macro: Space attachments. But there you can not order by size. 

Hope this helps

Pavel Potcheptsov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 20, 2019

Hi @Dominic Lagger 

I want to see files on the whole instance, not on dedicated page or space.

Let's say I want to identify files that occupy too much space on server.

Dominic Lagger
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 20, 2019

Out of the box, I don't know how that's supposed to work.

Here are two workarounds:

  • Are you able to connect to the database? 
    • The information is stored in the tables content and contentproperties (LONGVAL)
  • Confluence Command Line Plugin (documentation). I don't know the plugin, but it seems, that there is a function, which gives you all attachments. 
Like Pavel Potcheptsov likes this
Pavel Potcheptsov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 20, 2019

Yes I can connects to database.

It looks like I can find filename from first table and it's size from second.

select TITLE, SPACENAME, round(concat(LONGVAL/1024/1024), 0) as Size
from CONTENT, SPACES, CONTENTPROPERTIES
where CONTENT.CONTENTTYPE = 'ATTACHMENT'
and CONTENT.CONTENTID = CONTENTPROPERTIES.CONTENTID
and SPACES.SPACEID = CONTENT.SPACEID
and CONTENTPROPERTIES.PROPERTYNAME = 'FILESIZE'
order by CONTENTPROPERTIES.LONGVAL DESC

 

Like Dominic Lagger likes this
WW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 25, 2022

I'm ok with seeing the attachments in only one space and sorting by size.  However, there are 91 pages of attachments when I use the Space Attachments macro. 

When I click the Size column header to sort, it doesn't work.  The sorting changes, but not to any recognizable pattern I can tell; not alphabetical, numerical, or combination thereof.

Looks like there's a known bug/issue for this.  With my vote, that makes 2. :(

CONFSERVER-56047

It did work for a smaller space with only one page of attachments, though.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events