title: How to encode an attachment to Base64 in Jmeter?
body: <p>I'm trying to encode a file to Base64 in Jmeter to test a web service using the following script:</p>
  
  <pre><code>String file = FileUtils.readFileToString(new File("${filepath}"), "UTF-8");
  vars.put("file", new String(Base64.encodeBase64(file.getBytes("UTF-8"))));
  </code></pre>
  
  <p>This works fine for plain/text files and does not work for other file types correctly.</p>
  
  <p>How could I make it work for other file types?</p>