title: How correct send encoded base64 image to nodeJS and get response in Java
body: <p>I would like using HttpClient to invoke a service (localhost/png/ 'imageWithBase64')
  which will return me answer from the variable 'result'. Ocrad.js reads a basic, simple text with images.</p>
  
  <p>I have 3 questions:
  - How to send Java is base64 encoded to the service?
  - And whether paste this id to img.src will work correctly?
  - The result returned with the form of JSON or HTML format?</p>
  
  <p>Currently, I get a bug in Java (I can not send the entire String as a parameter id to the service)</p>
  
  <pre><code>java.lang.IllegalArgumentException: Illegal character in path
  </code></pre>
  
  <p>Code Java:</p>
  
  <pre><code>        File file = new File(getClass().getClassLoader().getResource("test.png").getFile());
  
          String encodedFile = Base64.encode(FileUtils.readFileToByteArray(file));
  
          String url = "http://127.0.0.1:3000/png/"+encodedFile;
  
          HttpClient client = HttpClientBuilder.create().build();
          HttpGet request = new HttpGet(url);
  
          HttpResponse response = client.execute(request);
  
          BufferedReader rd = new BufferedReader(
                  new InputStreamReader(response.getEntity().getContent()));
  
          StringBuffer result = new StringBuffer();
          String line;
          while ((line = rd.readLine()) != null) {
              result.append(line);
          }
  
          System.out.println(result.toString());
  </code></pre>
  
  <p>My Java Dependency:</p>
  
  <pre><code> &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
              &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
              &lt;version&gt;4.4.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
              &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
              &lt;version&gt;1.3.2&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  </code></pre>
  
  <p>And server with nodeJS:</p>
  
  <pre><code>var express = require('express');
  var OCRAD = require('ocrad.js');
  var Canvas = require('canvas');
  var Image = Canvas.Image;
  
  var app = express();
  
  app.get('/png/:id', function(req, res) {
  
  var img = new Image();
  img.src = 'data:image/png;base64,'+req.params.id; 
  var canvas = new Canvas(img.width, img.height);
  var ctx = canvas.getContext('2d');
  ctx.drawImage(img, 0, 0, img.width, img.height);
  var result = OCRAD(canvas);
  res.send({result:result});
  });
  
  app.listen(3000);
  console.log('Listening on port 3000...'); 
  </code></pre>