Expand my Community achievements bar.

SOLVED

How to handle duplication in assets using HTTP assets API?

Avatar

Level 2

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?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@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.

View solution in original post

3 Replies

Avatar

Employee Advisor

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.ht... 

 

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

 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-assets-duplication-det...

 

Hope that helps!

 

Regards,

Nitesh

 

Avatar

Correct answer by
Community Advisor

@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.

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