Search code examples
jmeterjmeter-5.0

JMeter - Issues with Image Upload for API Request. Recording doesn't work


  1. If I upload an image on Postman using only binary option it works. If I use form-data to upload a file on Postman the image file gets corrupted with unnecessary appended info. So I tried to record JMeter script while uploading image on Postman using binary option. But the image size grew from 279kb to 509kb and I got a corrupt image. It's only 279kb when I send on Postman without recording. See pictures below.

  2. If I use the "Files Upload" tab on JMeter HTTP Request, it appends info as below making the image file corrupt. The JAVA implementation on Advanced tab doesn't work either. --WNAkrdOzMmE0iZxPNbdHVVPxuBwgUX Content-Disposition: form-data; name="source"; filename="fileupload.jpg" Content-Type: image/jpeg

Can someone please provide me Groovy or BeanShell code to upload multiple image files one by one? Or, if there is a way to capture the traffic properly without the image file getting corrupt with additional data, please let me know and I can try. Thanks. Same picture but bigger size when recording in JMeter

Original size when sending only from Postman using binary option


Solution

  • binary file upload means that the file is being send as the HTTP Post request body

    JMeter's equivalent configuration would be:

    1. Switch to the Files Upload tab of the HTTP Request sampler
    2. Provide full or relative path to the file you want to upload
    3. Other fields should remain intact

    enter image description here

    More information: JMeter Performance Testing: Upload and Download Scenarios