title: How to post byte array via RestTemplate
body: <p>Goal: Post Image using RestTemplate</p>
  
  <p>Currently using a variation of this</p>
  
  <pre><code>MultiValueMap&lt;String, Object&gt; parts = new
  LinkedMultiValueMap&lt;String, Object&gt;();
  parts.add("field 1", "value 1");
  parts.add("file", new
  ClassPathResource("myFile.jpg"));
  template.postForLocation("http://example.com/myFileUpload", parts); 
  </code></pre>
  
  <p>Are there any alternatives? Is POSTing a JSON that contains a base64 encoded byte[] array a valid alternative?</p>