title: Receiving binary image from client and saving it on server side
body: <p>I am working on a Spring-MVC application where for the clientSide I am using html2canvas function to take screenshot and then I would like to send it to server for further processing and conversion. I am posting the code for html2canvas below. So I have a controller mapping which can read byte array, but I am just unable to pass it to the server, I keep getting error(also displayed below). 
  Finally, I would like to receive the binary image and save it in server side. Kindly let me know.</p>
  
  <p>Error :</p>
  
  <pre><code>INFO: Error parsing HTTP request header
   Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
  </code></pre>
  
  <p>Html2Canvas code :</p>
  
  <pre><code> $(".description").click(function(){
  
                 html2canvas($('body'), {
  
                      onrendered: function(canvas) {
  
                          var img = canvas.toDataURL("image/png");
  
                          $('&lt;img&gt;',{src:img}).appendTo($('#canvas-image'));
  
                      }
  
                      });
  </code></pre>
  
  <p>Controller code :</p>
  
  <pre><code>@RequestMapping("/convertbase/{id}")
      public String convertbase(@ModelAttribute("notices") Notes p,@PathVariable("id") byte[] id,Model model){
           byte[] data = org.apache.commons.codec.binary.Base64.decodeBase64(id);
          try {
  
              FileOutputStream imageoutfile = new FileOutputStream("/home/akshay/check.png");
              imageoutfile.write(data);
              imageoutfile.close();
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
      return "redirect:/note/listing";
      }
  </code></pre>
  
  <p>What am I doing wrong, any pointers would be helpful. Thank you for your time.</p>
  
  <p>New Controller :</p>
  
  <pre><code>@RequestMapping(value = "/convertbase/{id}",method = RequestMethod.POST)
      public String convertbase(@RequestBody String body){
           byte[] b = body.getBytes();
           byte[] data = org.apache.commons.codec.binary.Base64.decodeBase64(b);
           try {
  
              FileOutputStream imageoutfile = new FileOutputStream("/home/akshay/check.png");
              imageoutfile.write(data);
              imageoutfile.close();
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
      return "redirect:/note/listing";
      }
  </code></pre>
  
  <p>Ajax request :</p>
  
  <p>$(".description").click(function(){</p>
  
  <pre><code>       html2canvas($('body'), {
  
              onrendered: function(canvas) {
  
                  var img = canvas.toDataURL("image/png");
  
                  $('&lt;img&gt;',{src:img}).appendTo($('#canvas-image'));
  
                  $.ajax({
  
                        url: '../convertbase',
  
                        type: 'POST',
  
                        data:{image:img}
  
                  });
  
              }
  
              });
  </code></pre>