How can I upload files to Mendix application via JMeter?

0
Hi! I am trying to use JMeter for load testing. I'm able to do login, create a new data, and commit the data. However, if I try to do file upload I encouter the following message. <html><body><textarea>{"type":"exception","description":"Uploading file failed: uploadFIle.csv (of class java.lang.String)","result":560}</textarea></body></html>   I set  HTTP Request  in JMeter as followings; Method : POST Path : /file?guid=${fileguid}?maxFileSize=5 Use multipart/form-data for POST : enable Iset a file in Files Upload tab. I set 'Java' to Client implementation in Advanced tab. I set  HTTP Header Manager in JMeter as followings; Content-Type: multipart/form-data The result is as followings; Does anyone have any experience with file upload via JMeter in combination with Mendix, and please let me know what I am missing ? Thanks in advance, Satomi
asked
2 answers
1

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.

  • Method : POST
  • Path : /file?guid=${fileguid}?maxFileSize=5
  • Add a parameter  named 'data' , and replaced file's GUID and fileID.
  • Use multipart/form-data for POST : enable
  • set a file in Files Upload tab.
  • set 'Java' to Client implementation in Advanced tab.

- 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,

 

answered
0

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

answered