How to read XML file from DAM and place it in JCR? | Adobe Higher Education
Skip to main content
July 12, 2018

How to read XML file from DAM and place it in JCR?

  • July 12, 2018
  • 1 の返信
  • 6508 ビュー

Hi,

I have a requirement wherein i have to read xml file from dam and place that data under nodes in JCR.

Kindly help on this!

このトピックへの返信は締め切られました。

1 の返信

arunpatidar
Community Advisor
Community Advisor
July 12, 2018
Arun Patidar
July 12, 2018

Arun,

Thanks,But this doc tells how to read xml file from our local/desktop.But my question is how from aem dam? Any api and how to use it.

arunpatidar
Community Advisor
Community Advisor
July 12, 2018

Hi,

You can use Node API to read XML from DAM.

Example:

Node node = req.getResourceResolver().getResource(qs.toString()+"/jcr:content").adaptTo(Node.class);

InputStream in = node.getProperty("jcr:data").getBinary().getStream();

  BufferedReader reader = new BufferedReader(new InputStreamReader(in));

          StringBuilder out = new StringBuilder();

          String line;

          while ((line = reader.readLine()) != null) {

              out.append(line);

          }

          reader.close();

  log.debug("File DATA ==> " + out.toString());

aem63app-repo/ReadFileServlet.java at master · arunpatidar02/aem63app-repo · GitHub

Thanks

Arun

Arun Patidar