What APIs should be used to create a XML file in AEM? | Community
Skip to main content
Level 2
January 2, 2022
Solved

What APIs should be used to create a XML file in AEM?

  • January 2, 2022
  • 1 reply
  • 1138 views

We create a AEM pages using PageManager class. Like this I want to create a XML file dynamically and store in DAM location. Can anyone tell me what API should be used to create a XML files in AEM?

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 arunpatidar

Hi,

You need to use Asset API

 

 com.day.cq.dam.api.AssetManager assetMgr = resourceResolver.adaptTo(com.day.cq.dam.api.AssetManager.class);
assetMgr.createAsset(<attachmentPath>, <input stream>,<contentType>, true);
 
 for XML files, contentype = 'application/xml'

 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/upload-assets-to-aem-using-api/m-p/432744#M123333

 

1 reply

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
January 3, 2022

Hi,

You need to use Asset API

 

 com.day.cq.dam.api.AssetManager assetMgr = resourceResolver.adaptTo(com.day.cq.dam.api.AssetManager.class);
assetMgr.createAsset(<attachmentPath>, <input stream>,<contentType>, true);
 
 for XML files, contentype = 'application/xml'

 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/upload-assets-to-aem-using-api/m-p/432744#M123333

 

Arun Patidar
Level 2
January 3, 2022

Thank you Arun_Patidar