cancel
Showing results for 
Search instead for 
Did you mean: 

Adding filters for extensions.

shibu
Champ in-the-making
Champ in-the-making
In /share/components/upload folder, we are having some js files like dnd-upload.js, file-upload.js, flash-upload.js, html-upload.js. I can see one line in file-upload.js like;

<filter: {array},         // limits what kind of files the user can select in the OS file selector


I modified file-upload.js and html-upload.js files.
Modified files are attaching with this.

But this didnt block uploading image files.
How can I block uploading files by adding extensions into the filter?
8 REPLIES 8

niketapatel
Star Contributor
Star Contributor
I am not sure what this filter does exactly.

But logically once you upload a file then alfresco detects its mimetype so its late to restrict specific mimetype.

You may develop custom rule to delete content of specific mimetype or can develop behavior which implements NodeService Policy, Specifically onCreateNode.

shibu
Champ in-the-making
Champ in-the-making
I hope that the filter will block the files on upload.
There is a commented line in all upload js files like;
  filter: {array},         // limits what kind of files the user can select in the OS file selector


I can execute a script with the rule for deleting some mime types.
The problem is , if I am deleting exe files with a check like ;
if(document.mimetype == "application/octet-stream")
{
document.remove();
}

this will not allow to create folder also, becz folder also will be deleted on creation. That is a big problem.  Is there any way to solve it?
OR
How can I create a rule to delete files with specific extensions?

niketapatel
Star Contributor
Star Contributor
Sorry , I am not sure but I dont get this, your script also deleted the folder.

Your script looks OK and "docuement" object that also refers to content.

You have applied this rule specifically for "cm:content" or for "All Items".

If you have not defined any condition while applying rule then can you please try with cm:content! This script should work as expected - It should not delete folder

shibu
Champ in-the-making
Champ in-the-making
It worked. It was for "All Items". Changed for "cm:content".
Is there any way to delete from Trashcan also? I dont want to keep it any trashcan too.

Hi Shibu,

In the same scrip add temporary aspect. document.addAspect("sys:temporary). It will directly delete the file without moving it to trashcan. Hope it helps

It worked fine…

sujaypillai
Confirmed Champ
Confirmed Champ

shibu
Champ in-the-making
Champ in-the-making
I have checked. Please have a look into the attachments in the first post. I have used the filter discussed in the StackOverflow. But its not working. Please check those attachments once.