aem 6.5 | want to create json file in aem dam programmatically | Community
Skip to main content
Level 2
January 22, 2024
Solved

aem 6.5 | want to create json file in aem dam programmatically

  • January 22, 2024
  • 3 replies
  • 1960 views

Hi

i have some json output with me in my java code and that i want to store in a json file in aem dam. Which api should i use ? Asset http api or asset manager api ? And please share code for that

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 Saravanan_Dharmaraj

@sumansatija4 if you are creating json inside the AEM, use AssetManager API

AssetManager assetManager = resourceResolver.adaptTo(AssetManager.class);
if(assetManager != null){
assetManager.createAsset("/location/in/jcr", "application/json", true);
}

 

3 replies

Saravanan_Dharmaraj
Community Advisor
Saravanan_DharmarajCommunity AdvisorAccepted solution
Community Advisor
January 22, 2024

@sumansatija4 if you are creating json inside the AEM, use AssetManager API

AssetManager assetManager = resourceResolver.adaptTo(AssetManager.class);
if(assetManager != null){
assetManager.createAsset("/location/in/jcr", "application/json", true);
}

 

Level 2
January 23, 2024

But this one is deprecated right ?

Saravanan_Dharmaraj
Community Advisor
Community Advisor
January 23, 2024

@sumansatija4 yes, please see the second message i sent for more information.

kautuk_sahni
Community Manager
Community Manager
January 23, 2024

@sumansatija4  Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni
EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 23, 2024

The practice of programmatically creating 'assets' is discouraged in AEMaaCS due to the Assets Architecture. Further information on this can be found here: https://github.com/adobe/aem-upload?tab=readme-ov-file#background

 

"aem-upload" is recommended for uploading assets to AEMaaCS but I think it is not what you are looking for. I recommend reconsidering the necessity of creating an asset in AEM programmatically. If the goal is to store information (such as JSON), consider using a node or its properties instead.

Hope this helps

Esteban Bustamante