Expand my Community achievements bar.

Registration for the AEM Guides Expert Session on “Native PDF Publishing - Learning by Example (part 1)” is open.
SOLVED

Testing Extract Servlet Meta data

Avatar

Level 1

SlingHttpServletResponse.getOutStream is coming as null while running the test case

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hi,

 

getOutputStream is used for writing the binary content. If I understand your usecase correctly you are trying to read from the servlet response. In this case you can do something like -

 

ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(response.getOutput());
BufferedImage image = ImageIO.read(byteArrayInputStream);

and then you can read metadata from the image object. 

1 Reply

Avatar

Correct answer by
Level 4

Hi,

 

getOutputStream is used for writing the binary content. If I understand your usecase correctly you are trying to read from the servlet response. In this case you can do something like -

 

ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(response.getOutput());
BufferedImage image = ImageIO.read(byteArrayInputStream);

and then you can read metadata from the image object. 

page footer
Change Username