Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

How do I get past 401 error on downloading and image from DAM

Avatar

Level 6

When executing

    javax.jcr.Session session = repository.login(new SimpleCredentials(
                    "admin", "admin".toCharArray()));
            

BufferedImage image =   ImageIO.read(new URL(imageurl));

 

Where imageurl is the localhost path to my dam jpg file

 

I get error 401. How, do I use my Session obbject to allow   ImageIO.read(new URL(imageurl)) to access the session?

 

regards

1 Accepted Solution

Avatar

Correct answer by
Level 10

For the URL object you need to attach Authorization http://stackoverflow.com/questions/496651/connecting-to-remote-url-which-requires-authentication-usi...

OR from session get the node & then inputstream and pass to ImageIO

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

For the URL object you need to attach Authorization http://stackoverflow.com/questions/496651/connecting-to-remote-url-which-requires-authentication-usi...

OR from session get the node & then inputstream and pass to ImageIO