title: Save base64 encoded data sent over http as binary with browser
body: <p>I'm writing a REST service that allows the receipt of a binary file resource.</p>
  
  <p>I'm using RESTEXPRESS and I send the binary data as encoded base64 string over HTTP.</p>
  
  <p>I have a combination of headers that allow the file to be received as an attachment but the browser does not decode the base64 back to binary.</p>
  
  <p>Is my goal possible? To send arbitrary binary fileformat over http and have the browser decode from base64 to binary automatically and save the file. Or have the browser trigger an application associated with file-extension? Can I do this transparently Or do I have to use javascript?</p>
  
  <p>Code showing the headers I use is listed below.</p>
  
  <pre><code>public String read(Request request, Response response) throws IOException
      {
          response.setIsSerialized(false);
  
          response.setContentType("application/arbitraryBinaryFileFormat");
  
          response.addHeader("Content-Transfer-Encoding", "Base64");
  
          response.addHeader("Content-Encoding", "Base64");
  
          response.addHeader("Content-Disposition","attachment; filename=r.arbitraryBinaryFileFormat");
  
          String result = encodeFileToBase64Binary("/Users/xxx/Downloads/r.arbitraryBinaryFileFormat");
          response.setBody(result);
          return result;
      }
  </code></pre>