Skip navigation

CQ5

kmkwarrior
Currently Being Moderated

How Read image from slingRequest

Apr 4, 2012 9:52 PM

Hi,

 

We have a user input form which contains input file (image) selection. When user submits the form, we want to read the file selected by user and store it as base 64 encoded data. We have following code to do the same. This code gets executed when the form is submitted.

 

//Read image data from slingRequest

String userImage1 = slingRequest.getParameter("userImage1");

 

//Apply base 64 encoding on the data received in slingRequest

String encodedUserFile = "";

byte[] userFileBytes = userImage1.getBytes();

encodedUserFile = Base64.encodeBase64String(userFileBytes);

 

These statements are not throwing any error. But, when I try to apply base 64 decoding on the contents available in 'encodedUserFile', its' not the image user uploaded. There seems to be some problem, which I am not able to figure out. Can someone please help me with this?

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points