Expand my Community achievements bar.

SOLVED

AEM Assets duplication detection through api upload

Avatar

Level 3

Is it possible to leverage the AEM Assets duplicate detection functionality when uploading assets through an API process?
I found this post that feels similar to the response that, yes it could be possible to build that into an API to initiate the check and provide the API to take action based on a response.

AEM Cloud Service - Assets server side check for D... - Adobe Experience League Community - 401019

Thank you!

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi @james-mke ,

You are seeing the right documentation. There is no OOTB way to detect the duplicate images when you upload through the asset API. The configured OOTB functionality works when you upload it via browser UI or through AEM desktop. 

For Asset API, in this documentation http://experience-aem.blogspot.com/2021/03/aem-cloud-service-assets-server-side-check-for-duplicate-... you will have to write the filter which is this point 

3) Add a filter apps.experienceaem.assets.core.filters.DuplicateAssetNameCheck executing for .initiateUpload.json and .createasset.html requests to check for duplicate file names across the repo

This filter will be called every time the request happens to upload asset using the asset API. See the 

"sling.filter.pattern=((.*.initiateUpload.json)|(.*.createasset.html))",

this defines when this filter will be called. include this java class in your code and verify. You can modify the logic as per your requirement - to throw error or to upload and just log a message or something else.

View solution in original post

3 Replies

Avatar

Community Advisor

Hi,

 

You can enable the below config for duplicate asset detention

https://experienceleague.adobe.com/docs/experience-manager-64/assets/managing/duplicate-detection.ht...

 

Once enabled, when uploading same asset, we will get error like below

 

Screen Shot 2022-05-04 at 7.49.51 AM.png

Avatar

Level 3

Hello Ravi,

That did not fully answer my question. Does this duplicate detection functionality also support uploads through APIs?

 

Avatar

Correct answer by
Employee Advisor

Hi @james-mke ,

You are seeing the right documentation. There is no OOTB way to detect the duplicate images when you upload through the asset API. The configured OOTB functionality works when you upload it via browser UI or through AEM desktop. 

For Asset API, in this documentation http://experience-aem.blogspot.com/2021/03/aem-cloud-service-assets-server-side-check-for-duplicate-... you will have to write the filter which is this point 

3) Add a filter apps.experienceaem.assets.core.filters.DuplicateAssetNameCheck executing for .initiateUpload.json and .createasset.html requests to check for duplicate file names across the repo

This filter will be called every time the request happens to upload asset using the asset API. See the 

"sling.filter.pattern=((.*.initiateUpload.json)|(.*.createasset.html))",

this defines when this filter will be called. include this java class in your code and verify. You can modify the logic as per your requirement - to throw error or to upload and just log a message or something else.