How to handle duplication in assets using HTTP assets API? | Community
Skip to main content
Manisha_Mirchandani
Level 2
February 13, 2023
Solved

How to handle duplication in assets using HTTP assets API?

  • February 13, 2023
  • 2 replies
  • 1134 views

Hi,

 

we have a requirement to check if the asset exists in the /content/dam path, the new file needs to over write the existing file.

 

is there any way to handle duplication in assets?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jagadeesh_Prakash

@manisha_mirchandani 

Yes, there are several ways to handle duplicates in assets in Adobe Experience Manager (AEM). Here are a few approaches you can consider:

  1. Overwrite existing assets: You can overwrite existing assets in AEM by using the same path to upload a new asset. When you upload a new asset with the same path as an existing asset, the new asset will replace the existing asset. This approach will allow you to overwrite existing assets in the /content/dam path.

  2. Automatically rename new assets: You can configure AEM to automatically rename new assets if a file with the same name already exists in the same folder. You can do this by setting the dam.auto.rename property to true. With this setting, AEM will append a unique identifier to the file name of new assets to ensure that no files are overwritten.

  3. Custom duplicate handling: You can write custom code to handle duplicates in assets in AEM. For example, you can write a custom servlet that checks if an asset with the same name already exists in the /content/dam path and performs some custom logic to handle duplicates. This approach will give you full control over how duplicates are handled in AEM.

These are just a few of the options available to handle duplicates in assets in AEM. The best approach will depend on your specific requirements and the constraints of your project.

2 replies

nitesh_kumar-1
Adobe Employee
Adobe Employee
February 13, 2023

Hi @manisha_mirchandani ,

 

for the upload through UI, there is a feature you can enable:-

https://experienceleague.adobe.com/docs/experience-manager-65/assets/managing/duplicate-detection.html?lang=en 

 

However, for Assets API, afaik you need to write custom logic to detect and handle it, take a look at this blog post and thread if not already.

http://experience-aem.blogspot.com/2021/03/aem-cloud-service-assets-server-side-check-for-duplicate-file-names.html 

 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-assets-duplication-detection-through-api-upload/m-p/450718

 

Hope that helps!

 

Regards,

Nitesh

 

Jagadeesh_Prakash
Community Advisor
Jagadeesh_PrakashCommunity AdvisorAccepted solution
Community Advisor
February 13, 2023

@manisha_mirchandani 

Yes, there are several ways to handle duplicates in assets in Adobe Experience Manager (AEM). Here are a few approaches you can consider:

  1. Overwrite existing assets: You can overwrite existing assets in AEM by using the same path to upload a new asset. When you upload a new asset with the same path as an existing asset, the new asset will replace the existing asset. This approach will allow you to overwrite existing assets in the /content/dam path.

  2. Automatically rename new assets: You can configure AEM to automatically rename new assets if a file with the same name already exists in the same folder. You can do this by setting the dam.auto.rename property to true. With this setting, AEM will append a unique identifier to the file name of new assets to ensure that no files are overwritten.

  3. Custom duplicate handling: You can write custom code to handle duplicates in assets in AEM. For example, you can write a custom servlet that checks if an asset with the same name already exists in the /content/dam path and performs some custom logic to handle duplicates. This approach will give you full control over how duplicates are handled in AEM.

These are just a few of the options available to handle duplicates in assets in AEM. The best approach will depend on your specific requirements and the constraints of your project.

Manisha_Mirchandani
Level 2
February 14, 2023

Thanks @jagadeesh_prakash for multiple solutions, will try to implement which fits best according to the requirement.