Restrict Attachments Based on File Type

Andrei [errno] Community Champion Jul 22, 2011

What do people do to restrict .bmp uploads? :) no matter how big a font in how-tos I use - people still ignore. I also would like to restrict .exe uploads.

I know of https://jira.atlassian.com/browse/CONF-6931 but it had not seen much progress...

I would not want to do it completely right - looking into the file, understanding it's format; just a basic extension filter would work for most abusers. thanks!

3 answers

1 vote
Colin Goudie Community Champion Jul 22, 2011

Have a look at overriding the 'attachfile' action

 <action name="attachfile" class="com.atlassian.confluence.pages.actions.AttachFileAction">

You can do this via the conveyor plugin

http://wiki.customware.net/repository/display/AtlassianPlugins/Confluence+Conveyor+Library

0 vote
Matt Ryall Atlassian Team Feb 28, 2013

You can implement this as a servlet filter module in a plugin which intercepts all multipart requests and allows or denies them based on the filename in the request.

I'd look at the AttachFileAction in the Confluence source code as an example of how to handle multipart requests.

Overriding the actions in Confluence as Colin suggests is probably not a great idea. His example there only covers some of the ways in which attachments are added to Confluence.

Hi Matt,

I want to write a plugin that prevents users to update attachments in Confluence. The only way I see is to check during the file upload if an attachment with the same name aleady exists. If yes the request should be canceled (ideally with a note for the user) or the file should be renamed. If I understand you correctly, this should also be possible with a servlet filter module. I read the description, but I am not sure how to identify upload requests. Can you provide some help?

Hi errno,

You can use this add-on to restrict attachment based on file types https://marketplace.atlassian.com/plugins/com.elitesoftsp.confluence.attachment.tool.plugins/server/overview

It works well with my system.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

1,785 views 25 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you