0
votes

We have two file upload api's. One for uploading resume and other for uploading profile picture. Upload resume api takes one file as parameter. I tried below code.

------WebKitFormBoundaryPTjnjok43Hg6SN0w
Content-Disposition: form-data; name="file"; filename="sample.pdf"
Content-Type: application/pdf
Content-Transfer-Encoding: binary

${__FileToString(${P_ResumeFileLocation},,)}

------WebKitFormBoundaryPTjnjok43Hg6SN0w--

API is passing. However if I download the uploaded file, it is not showing any data. Later i tried multipart/form-data option and gave file location in file upload tab. API is getting passed and I can see data correctly after downloading same.

I went ahead and tried the same for upload picture api too. This api needs file, width and height parameters to be passed. I created two parameters in parameters tab and placed the file details in file-upload tab. API failed saying invalid method. Actually API takes file as first parameter and width, height later. In jmeter request tab I can see file is passed at last.

And i tried below code also:

------WebKitFormBoundaryRo2HSZXcGbDUiLyU
Content-Disposition: form-data; name="file"; filename="samplepicture.jpg"
Content-Type: image/jpeg
Content-Transfer-Encoding: binary

${__FileToString(${P_ProfileImageLocation},,)}
------WebKitFormBoundaryRo2HSZXcGbDUiLyU
Content-Disposition: form-data; name="width"

1000
------WebKitFormBoundaryRo2HSZXcGbDUiLyU
Content-Disposition: form-data; name="height"

1000
------WebKitFormBoundaryRo2HSZXcGbDUiLyU--

API is passing but i don't see a proper image when I download it.

I recorded the flow using fiddler. And I can re-issue the api request in fiddler successfully and can view image properly after downloading. I tried copying raw data from fiddler request, but no luck

I need to performance test those two api's using jmeter. Kindly let me know where I'm making mistake.

1

1 Answers

0
votes

If you can "record the flow using fiddler" you should be able to "record the flow" using JMeter, it's smart enough to generate the relevant HTTP Request sampler and HTTP Header Manager by capturing the request from the browser.

Just make sure to copy the picture to "bin" folder of your JMeter installation during recording otherwise it will fail, see Recording File Uploads with JMeter for more details.

P.S. "Raw" traffic from Fiddler can be replayed using HTTP Raw Request sampler