Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to restrict special characters for asset filenames in AEM DAM

ArunaSurukunta
Level 5
Level 5

Hi All,

If anyone implement or have idea on restricting special chanracters for filenames for assets Please let me know. Business users sometimes uploading files with special characters with asset files using touch UI and they are creating some issues. I wanted to to restrict such kind of situations.

 

I did some analysis on fileupload.js to restrict some characters but for some reason it is not working as I expected.

 

If any thoughts or suggestions on this implementation really help me.

1 Accepted Solution
Kiran_Vedantam
Correct answer by
Community Advisor
Community Advisor

Hi @ArunaSurukunta,

 

As you already know that the assets are uploaded in /content/dam. Hence, we can use the Event handling approach.

 

  1. Write an event listener/workflow/schedulers to listen to the event [node added/ removed etc.] of uploading the assets at the particular content path
  2. Fetch the file name and check for special characters
  3. Replace them with the characters which are generic, then save the node

You can refer to my post on different annotations here.

 

Hope this helps.

 

Thanks,

Kiran Vedantam.

View solution in original post

0 Replies
kunal23
Level 10
Level 10

You can write a request filter to validate the asset before it gets uploaded in AEM. 

 

You can find a sample of that filter here - http://experience-aem.blogspot.com/2018/11/aem-6420-file-decode-filter-virus-scan-to-decode-uploaded... 

 

ArunaSurukunta
Level 5
Level 5

@kunal23, Thank you.

 

I believe this is really good and helpful information.

Thanks a lot. I am going to try this and update you.

 

 Sorry, If it is a dumb question,  let's say I have implemented a filter to check the filename special chars and It is successfully removed characters from the filename. after that how to redirect to create asset servelet. Do I need to take any extra things to take care?

 

Thanks,

Aruna

 

Kiran_Vedantam
Correct answer by
Community Advisor
Community Advisor

Hi @ArunaSurukunta,

 

As you already know that the assets are uploaded in /content/dam. Hence, we can use the Event handling approach.

 

  1. Write an event listener/workflow/schedulers to listen to the event [node added/ removed etc.] of uploading the assets at the particular content path
  2. Fetch the file name and check for special characters
  3. Replace them with the characters which are generic, then save the node

You can refer to my post on different annotations here.

 

Hope this helps.

 

Thanks,

Kiran Vedantam.

View solution in original post

ArunaSurukunta
Level 5
Level 5

@Kiran_Vedantam

 

Thank you very much for your suggestion. I really appreciate it. 

 

When I upload assets into AEM DAM I am doing few extra operations such as running Graphics magics commands and writing the asset to another static server.

Because of these 2 operations, I am a little worried about the event listeners approach.

Otherwise, it is a really good suggestion and I am sure it is going to fix my issue if I don't have extra operations on the asset.

 

I also tried with Upload file JS but it is not helpful in case if I have china characters in filenames.

If you have any other solutions/suggestions please let me know.

 

Thank you once again.

 

ChitraMadan
Community Advisor
Community Advisor

Hi @ArunaSurukunta ,

 

You can also overlay the js file which is responsible for doing the validation and add your special characters in the list.

Please refer to this - https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/extending-file-name-valida...

ArunaSurukunta
Level 5
Level 5
@ChitraMadan, Thank you for the answer. I wanted to restrict spcial characters which are not a-z,A-z and 0-9. I did try this JS for some extent it is working. still i need to restrict other characters too. like CHinesee chars from the filenames. If you have any exposure to it please advise me.
BrianKasingli
Community Advisor
Community Advisor

@ArunaSurukunta,

You can configure the Day CQ DAM Asset Upload Restriction service from the OSGI console http://localhost:4502/system/console/configMgr/com.day.cq.dam.core.impl.mimeType.AssetUploadRestrict...

 

To restrict users to upload files of certain MIME types only, unselect the allow all MIME option and specify allowed MIME types in the Allowed Asset MIMEs (regex) fields using regular expressions.

Screenshot 2021-01-25 at 09.45.58.png