I'm having issue with Jmeter using BeanShell PreProcessor to encode input file then include the encoded file in "Send file with request".
Jmeter Setup
- HTTP Request (Send file with the request - ${file1})
- BeanShell PreProcessor
BeanShell PreProcessor
import org.apache.commons.io.FileUtils;
import org.apache.commons.codec.binary.Base64;
String file1 = FileUtils.readFileToString(new File("D:/File/test.txt"),"UTF-8");
vars.put("file1",new String(Base64.encodeBase64(file.getBytes("UTF-8"))));
Error Message
java.io.FileNotFoundException: ${file1} (The system cannot find the file specified)