title: Save base64 encoded image with jsf
body: <p>I'm using cordova/phonegap to capture image with device (currently iphone), the capturing is working fine, I get the base64 encoded image as a string in a callback:</p>
  
  <pre><code>    function handlePhotoSuccess(image){
          document.getElementById("uploadItemForm:picture").src = "data:image/jpeg;base64," + image;
          document.getElementById("uploadItemForm:imageBase64").value = image;
      }
  </code></pre>
  
  <p>The imageBase64 element is a hidden h:inputText.</p>
  
  <p>The image show correctly, but the saved value in the bean is not correct. It has like the image's 30% and the other part is gray.</p>
  
  <p>The value in the backing bean is a String, I convert it to a byte array, then save it:</p>
  
  <pre><code>    byte[] imageByte;
      BASE64Decoder decoder = new BASE64Decoder();
      try {
          imageByte = decoder.decodeBuffer(imageString);
          ByteArrayInputStream is = new ByteArrayInputStream(imageByte);
          temp.setContent(is); //temp will be saved to database
  
          images.put(currentAttribute.getId(), imageByte);
  
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>Maybe I do something wrong?</p>
  
  <p>Thank you in advance!</p>