How to add txt file programmatically in aem dam.
Hi All,
We have a requirement where we need to use the querybuilder search api and search the content path of the particular site and after that we need to add the searched content path in a txt file and we need to upload this file in aem dam. I have done all the thing except adding the txt file in the dam, even though I have added the code for this but the changes are not working. File is getting added in the aem dam but there is no content inside the file.
For uploading the content in dam I am using below code snippet.
AssetManager manager = resourceResolver.adaptTo(AssetManager.class);
is = new FileInputStream(site[2]+".txt");
log.info("inputstream value check:{}->",is.available());
Asset asset = manager.createAsset("/content/dam/" + site[2]+".txt", is, "text/plain", true);
Please help me on the above issue.
Thanks,
Aaqib Khan