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

Extending File Name Validation in AEM Assets

Avatar

Level 2

AEM 6.3 by default restricts some characters in file name.

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

dam_error1.JPG

1 Accepted Solution

Avatar

Correct answer by
Level 7

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):

code-change-here.png

Sample output:

upload-error.png

We hope this helps!

Regards,

TechAspect Solutions

View solution in original post

7 Replies

Avatar

Level 10

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.

Avatar

Level 5

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.

Avatar

Correct answer by
Level 7

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):

code-change-here.png

Sample output:

upload-error.png

We hope this helps!

Regards,

TechAspect Solutions

Avatar

Level 2

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,

 

Avatar

Level 1

Hi,

I'm trying to add this in AEM 6.5.11, but when I try to upload an image I get an error in the JavaScript console:

Uncaught TypeError: fileUpload.initialize is not a function
at fileupload.50a57a892a4fa689c0730dd4122f2dfb.js:2153:32
at iterate (fileupload.50a57a892a4fa689c0730dd4122f2dfb.js:2135:17)
at fileupload.50a57a892a4fa689c0730dd4122f2dfb.js:2149:13

I've overlaid fileupload.js at /apps/dam/gui/coral/components/commons/fileupload/clientlibs/fileupload/js/fileupload.js and as far as I can tell it is working as expected.

It's just not working.

Avatar

Level 5

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.")

Avatar

Level 2

Yes, I could find this file and it worked.

Thanks for your correct response.