Hi,
I want to restrict the uploading of certain file types. I tried to listen attachment event but the event is triggered after the file uploaded so it is useless.
I want to check the file type while uploading so the file won't be uploaded to server.
Community moderators have prevented the ability to post new answers.
Have you tried a servlet filter on /pages/doattachfile.action ?
Check this out:
https://developer.atlassian.com/display/DOCS/Servlet+Filter+Plugin+Module
Here is a little general how-to about servlet-filters:
http://www.oracle.com/technetwork/java/filters-137243.html
The only thing you have to do is to check the mime type of your upload and to decide if it's allowed or not...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, but after checking mime type of the file the request is not completed and it shows me "the page couldn't find" error even I upload an accepted file. What should I do no handle this situation and how can I display error message on the page like reacihng maximum file size limit?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why do you need to display an error for exceeding a maximum file size limit when Confluence already supports this out of the box? https://confluence.atlassian.com/display/DOC/Configuring+Attachment+Size
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Joseph, I didnot mean display error for exceeding a maximum file size limit, I meant "as red error line appear in the page when error for exceeding a maximum file size limit".
And it is not the main problem, the problem is that after getting file extension what should I do to let the upload process ends if extension is acceptable or do not let the upload process and return the previous page.
if (!item.isFormField()) if(item.getContentType().equals("application/x-msdownload")) return;// What should I do??????????
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can send a redirect to an error page, or try to figure out, how you can smash the upload action.
Another option would be to override the upload action with the conveyor-plugin. You can add your own code with your checks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.