title: Unable to getImage from request.getInputStream()
body: <p>I am trying to get a image bytes from the request attribute which is coming from a mobile applciation.</p>
  
  <p>The format of the  image that is sent upstream is BitMap.
  Encoded in Base64 Format.</p>
  
  <p>How to get the  bytes in the web application ?
  I am using the below code snippet in my web application which i am using to get the data from the mobile applicaition request.
  I am got struck with the code. I am not sure whether I am right or wrong.</p>
  
  <pre><code>byte[] line             = null;
  
      int noOfBytesRead;
      StringBuffer content    = new StringBuffer();
  
      HashMap&lt;String, Object&gt; lResultMap  =   null ;
  
      try 
      {
          log.info("request getInputStream: " + request.getInputStream());
          ServletInputStream sis  = request.getInputStream();
  
          line                    = new byte[128];
          noOfBytesRead           = sis.readLine(line, 0, 128);
          log.info("noOfBytesRead :1 " + noOfBytesRead);
  
          if (noOfBytesRead &lt; 3)
              return null;
  
          noOfBytesRead           = sis.readLine(line, 0, 128); // Reads the content disposition and form name and filename
  
          log.info("line :"+line+" adn the noOfBytesRead : 2 : "  +   noOfBytesRead);
  
          int numBytesToRead      = noOfBytesRead;
          int availableBytesToRead;
  
          while ((availableBytesToRead = sis.available()) &gt; 0) 
          {
              byte[] bufferBytesRead;
              bufferBytesRead     = availableBytesToRead &gt;= numBytesToRead ? new byte[numBytesToRead] : new byte[availableBytesToRead];
              sis.read(bufferBytesRead);
              content.append(new String(bufferBytesRead, Charset.forName("iso-8859-1")));
          }
          sis.close();
          log.info("The bytes is  : " +content.toString());
          byte[] image        =   null;
          image   =   content.toString().getBytes(Charset.forName("iso-8859-1")) ;
          log.info("image : "  +image);
  
  
          Base64Decoder decoder = new Base64Decoder();  
          byte[] imgBytes = decoder.decode(content.toString());
          log.info("imgBytes : decoded byted" + imgBytes);        
          lResultMap          =   new HashMap&lt;String, Object&gt;();
  
          lResultMap.put("content"    , imgBytes );
          log.info("content string buffer :  " +content);
          log.info("lResultMap : "  +lResultMap);
      } 
      catch (Exception e) 
      {
          e.printStackTrace();
          log.log(Level.SEVERE, e.getMessage(), e);
      }
  </code></pre>