Alfresco – Disabling file upload by MIME type with 1 line of JS code

Alfresco handles every file format, in fact there is no limitation out of the box in order to restrict allowed MIME types. Executables, databases and any other potentially harmful content can be stored inside.

Developers can control this feature easily by listening onCreateNode event from NodePolicy. However, system administrators and other users without this skill require a simpler way. Below this simple approach is described.

Creating a one line server JavaScript

Create a new file at Repository > Data Dictionary > Scripts named exception.js including following contents:

throw "Unsupported file format";

alfresco-mimetype-javascript

Creating one rule by every forbidden mime type

Following screen capture includes a folder rule in order to avoid users uploading binary files: previous JavaScript is executed for every new file being binary.

alfresco-mimetype-rule

Result

Once this rule is working, users will receive an Unsupported file format message every time a binary file is uploaded by using Alfresco Share.

alfresco-mimetype-share

On the other hand, uploading binary files to this folder by any other means (WebDAV, FTP, email…) will produce also this error.

This type of content will not be uploaded to Alfresco in any case.

Other resources

GitHub Addon – https://github.com/keensoft/alfresco-mimetype-blocker

Un comentario en “Alfresco – Disabling file upload by MIME type with 1 line of JS code

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s