cancel
Showing results for 
Search instead for 
Did you mean: 

How to block uploading files of certain mime-types?

alexsolomatin
Champ on-the-rise
Champ on-the-rise
Hi,

I use Alfresco 4.0.4 and 3.4.10.

Is it possible to block files of certain mime-types from being uploaded into Alfresco?
Ideally, it'll be very good if it can be easily set in repository properties, content model or something like these. But I don't know if this functionality exists.
As I also understood, this blocking cannot be done with help of content rules… Please correct me if I'm wrong.
And one more possible solution is to implement a custom AMP module which will prevent uploading unnecessary files. Right now I don't also know how to impement it because I don't see how implementing NodeServicePolicies.OnCreateNodePolicy can prevent node creation… Maybe there is another solution not connected with behaviour policies…

So, is there any appropriate solution for this problem?

Thanks in advance.
3 REPLIES 3

mrogers
Star Contributor
Star Contributor
No I don't think there is anything out of the box.  
And also mime type detection is done after uploading the content so its too late.

You can throw an exception from the onCreate policy.   Its not elegant but would prevent certain mimetypes.  
Or you could have a rule which simply deletes the unwanted content.   

Or depending upon the interface you may be able to chose files with certain file name patterns.

alexsolomatin
Champ on-the-rise
Champ on-the-rise
Thank you for the response!

abarisone
Star Contributor
Star Contributor
Hi,
Maybe it is useful to know that we managed to limit upload file size by overriding
org.apache.commons.fileupload.servlet.ServletFileUpload.java
and setting the maxFileSize property.
In the same way I think you can intercept the mimetype of the content coming along with the request and block upload.
It may seem not very elegant, but for our purpose worked fine, since we couldn't find any other workaround

Regards,
Andrea