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 ?
Ideas , suggestions welcomed
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...
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 .
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 :)
You could use org.apache.commons.fileupload.DiskFileUpload.parseRequest() in your servlet filter and then handle the FileItems.
Hi Niels ,
Can you please provide some code example on decorating the filter on the attach file action ?
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 .
I found this example that provides some pointers for the implementation :)
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 the AttachFile action, define an own class that extends the class AttachFile and override the doValidation() method.
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.
You can make a plugin to do that. Implement com.atlassian.jira.issue.AttachmentManager, the default implementation is com.atlassian.jira.issue.managers.DefaultAttachmentManager
You might want to check out the Attachment Checker for JIRA plugin.