How to bulk delete assets in AEMaaCS DAM

Saravana Prakash
2 min readDec 23, 2023

--

Photo by Julio Lopez on Unsplash

TL;DR — Adobe documentation didnt work.

We know Adobe tries very hard to keep Cloud Service clean, performant and is different from the AEM 6.5 On-prem world.

The recommended way to interact with assets is to use AEM Assets API. This is indeed game changer for DAM projects. The traditional AssetManager API is (unofficially) deprecated and Adobe recommends switching to aem-upload. This is a Node based aio tool, external to AEM, that interacts with AEM Cloud Service.

This is completely valid, especially considering, we DONT want to overload JVM with asset binaries. Instead hijack binary traffic to native cloud-based APIs.

Unfortunately, this API for delete operation is NOT working.

Problem Statement:

Want to delete large volume of assets.

While working on a DAM migration project, found a bug during middle of migration. It was more work to bandage, rather, was easier to rerun migration from scratch. I had to trash 500K assets and reimport after bugfix.

How to trash 500K assets?

We cant, from author, hit a delete button for each asset. Hitting delete from root folder, times out, sure fails. This was production, I couldn’t write, deploy any JMX/Schedulers to delete in controlled way.

Adobe Documentation didnt work:

I tried to write a simple python script that ll iterate through a static list of assets and call delete operation as instructed here.

This worked on RDE and Non-Prod environments. But Failed on Stage and Prod environment. Coz, the Delete operation is blocked by CDN at Stage and Prod environment. So first attempt to frame a curl command and setting -X DELETE to run delete method failed.

This curl failed

curl -u username:password "http://hostname:port/content/sample/node/to/delete.jpg" -X DELETE -H"Content-Type: application/json"

Solution:

Magic sauce was to add a -F”:operation=delete” and run as POST.

So, this curl worked

curl -u username:password -F":operation=delete" http://hostname:port/content/sample/node/to/delete.jpg

Finally created shell script to run the new curl command for 500K assets and they got deleted successfully.

--

--

Saravana Prakash

AEM Fullstack Enthusiast. Working on AEMCaaS, Adobe EDS, Adobe IO and other Adobe Marketing Cloud tools