How to Test Image Upload Functionality With JMeter
Need to load test the upload image functionality of your web app? Don’t search through endless forum threads looking for help! I’d like to show you—step by step— how easily this can be done via JMeter. Let’s take a closer look:
Setting up the JMeter Script
First, make sure that your HTTP request is set to “POST” and the "Use multipart/form-data for POST" box is checked.
Here are a few important points to consider in the ‘Send Files With the Request’ window:
- File path - If you test locally, make sure you give the full file path, including the file name. When using BlazeMeter, don’t add a path to the file, as it will automatically be placed in the jmeter/home/folder in the cloud
- Parameter Name - This must be the exact “name” attribute as it appears in the page source, otherwise the file won’t have a ‘destination.
- Mime Type - It goes without saying, but make sure you enter the correct one. If not, the upload process won’t work properly.
Here’s a list of common Image Mime Types:
- image/gif: GIF image
- image/jpeg: JPEG JFIF image
- image/png: PNG image
- image/svg+xml: SVG vector image
- image/tiff: TIF image
- image/vnd.djvu: DjVu image and multi-page document format
Want to Upload Several Files?
To do this, you'll need to “parameterize” the script a bit. Instead of the image file name that you see in the ‘Send Files With the Request’ window above, you’ll need to write ${imageName}. Next, add a ‘CSV Data Set Config’ element to the top of the script. This will read the file names from a CSV file and set them in a variable called “imageName.”
For example:
image1.png,image2.png,image3.png
If you want every user to upload all the files only once, choose “False” at ‘Recycle on EOF’ and “True” at ‘Stop thread on EOF.’ Of course, deciding on how to configure every script depends on the specific scenario.
Want to Run This Test in BlazeMeter?
If you want to run tests in the cloud for extremely high traffic loads and from multiple geographical locations, you might already be using BlazeMeter.
If so, this is super easy to do. In order to upload files/images in your scenario, you’ll need to upload them along with your JMX and any additional file your scenario requires. You can also ZIP them all, upload the archive and set up a test in BlazeMeter.
Great Jacob. So are you sure it's same with JMeter 4.0? It seems you're worked with JMeter 3.1, right? BR, Sam
How to use tcp sampler for image upload in Websocket connection