Skip to main content
Aug 10, 2022 6:13 AM UTC
Solved

How can I filter assets to get only folders from adobe aem assets api

Hi Folks,

I am trying filter the content of adobe aem assets api to get only folders and skip files to check whether parent folder have any sub folder.

 

I am refereeing  below url for adobe aem documentation regarding asset api :
https://experienceleague.adobe.com/docs/experience-manager-64/assets/extending/mac-api-assets.html?lang=en

Can anyone help me to know how to filter the content of asset api.

 

Thanks,

Sandeep

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Nikhil_Verma
Nikhil_VermaAccepted solution
Level 4
Aug 16, 2022 5:44 AM UTC

I think for what you're after, you need query builder instead of Assets API.

 

Try this: http://localhost:4502/bin/querybuilder.json?path=/content/dam&1_property=jcr:primaryType&1_property.value=sling:Folder

 

You should get a JSON output with a list of all folders inside DAM:

 

Folder structure in DAM:

3 replies

Nikhil_Verma
Level 4
Aug 12, 2022 5:34 AM UTC

I have the below folder structure in my AEM Assets containing a parent folder ('my-assets') which again contains 3 assets and 1 folder:

 

The Assets API on 'my-assets' folder returns below:

It is clear I see that for assets the 'properties' element has 'metadata' and dc:format' elements.

Whereas, for folders these elements don't exist.

Which makes sense, as dc:format and metadata nodes in CRX exists for assets and not folders.

So you can know whether it is a folder or an asset.

 

Translate
sandyT52Author
Aug 16, 2022 4:40 AM UTC

Thanks Nikhil for reply,

In my case metadata does not come, but i have done this using class field and it is working but to check this folders have sub-folders i am sending separate api calls for each folders and checking if it contains any folder or not which is time consuming, i need a way to send filter with request to check if it have folder or not
For file:

For folder :

 

 

Translate
Nikhil_Verma
Nikhil_VermaAccepted solution
Level 4
Aug 16, 2022 5:44 AM UTC

I think for what you're after, you need query builder instead of Assets API.

 

Try this: http://localhost:4502/bin/querybuilder.json?path=/content/dam&1_property=jcr:primaryType&1_property.value=sling:Folder

 

You should get a JSON output with a list of all folders inside DAM:

 

Folder structure in DAM:

Translate