Hi,
I finally found out that how to upload a file via JMeter.
The process is as follows;
1. create a HTTP Request 'POST' to upload file.
- value of the parameter 'data' is as follows,
- files Upload tab is as follows,
2. create another HTTP Request 'POST' to commit the file object.
I hope this will help someone.
Regards,
This is some Java i made for that a while ago:
System.out.println("--------------------------------------------------------------------------------");
System.out.println("instantiate");
System.out.println("--------------------------------------------------------------------------------");
//sample input
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("X-Csrf-Token", token);
reqObj=new JSONObject(
"{\"action\":\"instantiate\",\"params\":{\"objecttype\":\"System.FileDocument\"},\"context\":[]}"
);
resObj=rest.post(
url,
reqObj.toString(),
headers
);
if(resObj!=null){
System.out.println(resObj.toString());
}else{
System.out.println("NO RESPONSE!");
}
//extract object guid
str_guid=((JSONObject)resObj.get("mxobject")).get("guid").toString();
System.out.println("--------------------------------------------------------------------------------");
System.out.println("GUID extraction");
System.out.println("--------------------------------------------------------------------------------");
System.out.println("Object GUID extracted: "+str_guid);
System.out.println("--------------------------------------------------------------------------------");
System.out.println("submit content");
System.out.println("--------------------------------------------------------------------------------");
headers = new HashMap<String, String>();
headers.put("X-Csrf-Token", token);
String str_fileSubmitUrl="http://localhost:8081/file?&guid="+str_guid+"&maxFileSize=5&csrfToken="+token;
System.out.println("Attempting to submit to "+str_fileSubmitUrl+" ...");
reqObj=new JSONObject(
"{\"action\":\"instantiate\",\"params\":{\"objecttype\":\"System.FileDocument\"},\"context\":[]}"
);
resObj=rest.postFile(
new URL(str_fileSubmitUrl),
"./res/a.png",
headers
);
//usual response as per firefox network inspector:
//<html><body><textarea>{}</textarea></body></html>
if(resObj!=null){
System.out.println(resObj.toString());
}else{
System.out.println("NO RESPONSE!");
}
This sort of stuff is also highly dependent on runtime version, security and some other nasty things