Extending File Name Validation in AEM Assets | Community
Skip to main content
medhik
Level 2
Oct 26, 2017 5:47 PM UTC
Solved

Extending File Name Validation in AEM Assets

AEM 6.3 by default restricts some characters in file name.

How can I extend the restriction for a few more characters?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Techaspect_Solu
Techaspect_SoluAccepted solution
Level 7
Oct 29, 2017 5:06 PM UTC

Hi,

We were able to extend the filename name validation functionality to few more characters (say '-' here) in AEM 6.3 assets successfully. The following js file is responsible for filename validation:

/libs/dam/gui/coral/components/commons/fileupload/clientlibs/fileupload/js/fileupload.js

For extending the restriction functionality to few more characters, we need to overlay the above node (fileupload.js) and make the required changes in it.

Changes to be made in overlay location (/apps/dam/gui/coral/components/commons/fileupload/clientlibs/fileupload/js/fileupload.js):

Sample output:

We hope this helps!

Regards,

TechAspect Solutions

8 replies

Employee
Feb 28, 2023 10:28 PM UTC

This character list is now moved to /libs/dam/gui/coral/components/admin/clientlibs/damutil/js/util.js file which provides a helper function getInvalidFileChars  where any additional characters could potentially be added to the list.

Translate
medhik
medhikAuthor
Level 2
Oct 30, 2017 3:05 PM UTC

Yes, I could find this file and it worked.

Thanks for your correct response.

Translate
manoj_devapath
Level 5
Oct 30, 2017 2:05 PM UTC

If you are planning to use custom logic to aem asset com.day.cq.commons.jcr.JcrUtil

API is usefull.

<!-- https://mvnrepository.com/artifact/com.day.cq/cq-commons -->

<dependency>

    <groupId>com.day.cq</groupId>

    <artifactId>cq-commons</artifactId>

    <version>5.8.2</version>

    <scope>provided</scope>

</dependency>

JcrUtil ("The Adobe AEM Quickstart and Web Application.")

Translate
Techaspect_Solu
Techaspect_SoluAccepted solution
Level 7
Oct 29, 2017 5:06 PM UTC

Hi,

We were able to extend the filename name validation functionality to few more characters (say '-' here) in AEM 6.3 assets successfully. The following js file is responsible for filename validation:

/libs/dam/gui/coral/components/commons/fileupload/clientlibs/fileupload/js/fileupload.js

For extending the restriction functionality to few more characters, we need to overlay the above node (fileupload.js) and make the required changes in it.

Changes to be made in overlay location (/apps/dam/gui/coral/components/commons/fileupload/clientlibs/fileupload/js/fileupload.js):

Sample output:

We hope this helps!

Regards,

TechAspect Solutions

Translate
Level 2
Jan 18, 2022 5:36 AM UTC

Hi Team, 

 

I am trying to extend the same functionality. There are few more special characters like 'à','ç' (continuous pressing of 'A' in the keyboard will popup these values). So how can I restrict those values ?

 

Can I change the '_IILEGAL_FILENAME_CHARS' to 'Legal_FileName_Chars' and check the same functionality.

 

Thanks,

 

Translate
manoj_devapath
Level 5
Oct 29, 2017 1:37 PM UTC

We need a jcr event listener on new node created in dam. and then add your custom logic to rename the node. use node move logic and save the asset.

we did this custom logic implementation on page creation. its same for asset upload too.

Translate
smacdonald2008
Level 10
Oct 26, 2017 6:58 PM UTC

We asked Eng to look at this question. This logic is somewhere - i am not sure where as i have never read this use case before.

Translate