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
Solved! Go to Solution.
Views
Replies
Total Likes
@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);
}
@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);
}
One thing to note, if you are using AEM as Cloud service
com.day.cq.dam.api.AssetManager.createAsset(String, InputStream, String, boolean) |
In AEM as a Cloud Service, assets should instead take advantage of direct binary access. A discussion of this change as well as an SDK to ease implementation of this new pattern can be found at aem-upload.
|
---|
But this one is deprecated right ?
@SumanSatija4 yes, please see the second message i sent for more information.
But i am not using aem as cloud service i am working on aem 6.5
@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.
Views
Replies
Total Likes
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