Join thousands of Atlassian users for an unforgettable week of knowledge sharing, product training, networking, and fun. Atlassian Summit is Oct 10 - 13 in San Jose, CA – Register soon before tickets sell out.

Hi ,

I want to restrict uploading of attachments based on file type for example .exe ,.bat.

I was able to automatically change the status when we attach a file . Is there an available plugin which provides this functionality ?

can anyone plz guide me how i can apply such filter which restricts attaching a specified file type ?

Thanx :)

  1. Mizan

    Ideas , suggestions welcomed

CommentAdd your comment...

3 answers


    You could write a Plugin that exposes a Servlet Filter Module. This Servlet Filter decorates the attachment upload action, checks the filetype and display an error page (rendered directly or via redirect) to the user...

    1. Mizan

      I was trying webwork plugin module to extend the attach file action but was not able to get the file name and check its extension and display an error message. I will try Servlet Filter Module , this will be the first time il use this module, thanx .

    2. Naren

      Hi Niels,

      Thanks for the above answer!

      Even I am working on similar case. I tried writing a sevlet filter for intercepting the attachment upload request. But how should I get a attachment upload action and the file type being attached to the issue. I am looking at the AttachFile class. As I am new to this can you please guide me on this issue.

      Any help will be much appreciated :)

    3. Mizan

      Hi Niels ,

      Can you please provide some code example on decorating the filter on the attach file action ?

    4. Mizan

      Hi Niels ,

      In my servlet filter i get file name , i check for the name and print an error message in the log . However I want to know how i can print an error message to the user .

    5. Niels Jaeckel

      I found this example that provides some pointers for the implementation :)


    6. Niels Jaeckel

      Well, that's not easily possible. With the servlet filter you could just filter out unwanted files quietly.

      If you want a nice error message for the user you could try overriding[1] the AttachFile action, define an own class that extends the class AttachFile and override the doValidation() method.

      1: https://developer.atlassian.com/display/JIRADEV/Webwork+plugin+module#Webworkpluginmodule-OverridingaJIRAaction

    7. Naren

      Well, Thanks Niels, I was able to restrict the attachments of certain types without using the servlet filter and by simply extending the AttachTemporaryFile action and displaying the error message upon attaching files of certain types.

      Also you can try modifying the class files for this functionality, but have to keep a track of it during upgrades.

    CommentAdd your comment...

    You can make a plugin to do that. Implement com.atlassian.jira.issue.AttachmentManager, the default implementation is com.atlassian.jira.issue.managers.DefaultAttachmentManager

    1. Niels Jaeckel

      I think it is not possible to exchange the DefaultAttachmentManager via a Plugin. You would have to edit the Spring configs directly...

    CommentAdd your comment...

    You might want to check out the Attachment Checker for JIRA plugin.

      CommentAdd your comment...