{"id":5136,"date":"2018-08-24T13:57:29","date_gmt":"2018-08-24T17:57:29","guid":{"rendered":"https:\/\/www.redline13.com\/blog\/?p=5136"},"modified":"2018-08-24T13:57:29","modified_gmt":"2018-08-24T17:57:29","slug":"file-upload-with-jmeter","status":"publish","type":"post","link":"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/","title":{"rendered":"File Upload with JMeter"},"content":{"rendered":"<p>This article demonstrates how to do a file upload with JMeter. This will show the steps when you have a load testing scenario where file upload is required.<\/p>\n<h3><strong>Recording File Upload with JMeter<\/strong><\/h3>\n<p>The simplest way of creating a JMeter test plan is recording the corresponding request using the <a href=\"https:\/\/jmeter.apache.org\/usermanual\/component_reference.html#HTTP(S)_Test_Script_Recorder\">HTTP(s) Test Script Recorder<\/a>. JMeter acts as a proxy server, capturing all traffic between a web browser and the application under test (AUT), and converting it into the relevant HTTP requests.<\/p>\n<p>JMeter has predefined templates which we can use to create test plans. Follow the steps below to set up JMeter for recording.<\/p>\n<ol>\n<li>Click on File \u2192 Templates and choose Recording Template.<\/li>\n<li>Click the Create button.<\/li>\n<li>Configure your browser to use the JMeter proxy by providing the IP address of the machine where JMeter is running as proxy server and proxy port.<\/li>\n<li>Open your HTTP(S) Test Script Recorder and click on the start button to start recording.<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5137\" src=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-53.png\" alt=\"HTTP(S) Test Script Recorder\" width=\"1073\" height=\"603\" srcset=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-53.png 1073w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-53-300x169.png 300w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-53-1024x575.png 1024w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-53-768x432.png 768w\" sizes=\"auto, (max-width: 1073px) 100vw, 1073px\" \/><\/p>\n<p>JMeter generate a certificate named \u201cApacheJMeterTemporaryRootCA.crt\u201d file and stores it in the bin directory of JMeter. Install this certificate in your browser to capture HTTPS traffic. Now the setup is ready. Start performing your actions in a browser and JMeter captures the traffic and converts it to HTTP samplers as shown below.<\/p>\n<h3>Let\u2019s take a look at the recorded request in the Test Plan:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5138\" src=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-54.png\" alt=\"HTTP Request\" width=\"1366\" height=\"691\" srcset=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-54.png 1366w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-54-300x152.png 300w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-54-1024x518.png 1024w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-54-768x388.png 768w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/h3>\n<p>As you can see from the image above, JMeter correctly resolved the file name, which is\u00a0<strong>index.html<\/strong>, but didn\u2019t capture the full path to the file. This is a result of browser behaviour, as some browsers do not send the full path of the file which is being uploaded. That is why JMeter was not able to locate the file and send it along with the request.<\/p>\n<p>By default, JMeter looks for <strong>index.html<\/strong> in its bin folder. If you run the recorded script, it will fail because the file is not present in bin folder of JMeter.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5139\" src=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-55.png\" alt=\"Script failed\" width=\"1366\" height=\"728\" \/><\/p>\n<p>The solution is to copy the file to the bin directory of JMeter. This way JMeter will pick up the file using the relative path and you\u2019ll have a successful recording. Or you can give the absolute path in the HTTP sampler so that JMeter picks the file from the location specified from the HTTP sampler.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5140\" src=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-56.png\" alt=\"Absolute file path\" width=\"1366\" height=\"728\" srcset=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-56.png 1366w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-56-300x160.png 300w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-56-1024x546.png 1024w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-56-768x409.png 768w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/p>\n<p>Now if you run the script, JMeter picks the file from the absolute path and executes the HTTP sampler.<\/p>\n<h3><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5141\" src=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/word-image-57.png\" alt=\"Successful results\" width=\"1366\" height=\"728\" \/><\/h3>\n<p><strong>Redline13 Load Testing Cloud <\/strong>with<strong> JMeter<\/strong><\/p>\n<p>JMeter is a strong and compelling tool to perform load testing. You can complement it with <a href=\"https:\/\/www.redline13.com\">Redline13<\/a>, which lets you simulate up to 1 million users in a single developer-friendly, self-service platform. For more information on running a JMeter test in RedLine13, <a href=\"https:\/\/www.redline13.com\/blog\/2017\/02\/jmeter\/\">follow this article<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article demonstrates how to do a file upload with JMeter. This will show the steps when you have a load testing scenario where file upload is required. Recording File Upload with JMeter The simplest way of creating a JMeter test plan is recording the corresponding request using the HTTP(s) Test Script Recorder. JMeter acts as a proxy server, capturing all traffic between a web browser and the application under test (AUT), and converting it into<a class=\"more-link\" href=\"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/\">Read More &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":5144,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,7,35],"tags":[],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-user","4":"post-5136","6":"format-standard","7":"has-post-thumbnail","8":"category-blog","9":"category-jmeter","10":"category-load-testing"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.12 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>File upload with JMeter for Load Testing<\/title>\n<meta name=\"description\" content=\"How to do a file upload with JMeter. This will then show how the steps when you have a load testing scenario where file upload is required.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"File upload with JMeter for Load Testing\" \/>\n<meta property=\"og:description\" content=\"How to do a file upload with JMeter. This will then show how the steps when you have a load testing scenario where file upload is required.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/\" \/>\n<meta property=\"og:site_name\" content=\"RedLine13\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-24T17:57:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/recording.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"374\" \/>\n\t<meta property=\"og:image:height\" content=\"240\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"RedLine13\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"RedLine13\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/\"},\"author\":{\"name\":\"RedLine13\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/4acbcdcb8a9c72ec5a274e69c0ebea28\"},\"headline\":\"File Upload with JMeter\",\"datePublished\":\"2018-08-24T17:57:29+00:00\",\"dateModified\":\"2018-08-24T17:57:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/\"},\"wordCount\":453,\"publisher\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\"},\"articleSection\":[\"Blog\",\"JMeter\",\"Load Testing\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/\",\"url\":\"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/\",\"name\":\"File upload with JMeter for Load Testing\",\"isPartOf\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#website\"},\"datePublished\":\"2018-08-24T17:57:29+00:00\",\"dateModified\":\"2018-08-24T17:57:29+00:00\",\"description\":\"How to do a file upload with JMeter. This will then show how the steps when you have a load testing scenario where file upload is required.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.redline13.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"File Upload with JMeter\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#website\",\"url\":\"https:\/\/www.redline13.com\/blog\/\",\"name\":\"RedLine13\",\"description\":\"(Almost) Free Load Testing in the Cloud\",\"publisher\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.redline13.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\",\"name\":\"RedLine13\",\"url\":\"https:\/\/www.redline13.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg\",\"contentUrl\":\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg\",\"width\":300,\"height\":68,\"caption\":\"RedLine13\"},\"image\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/4acbcdcb8a9c72ec5a274e69c0ebea28\",\"name\":\"RedLine13\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514?s=96&d=mm&r=g\",\"caption\":\"RedLine13\"},\"sameAs\":[\"http:\/\/127.0.0.1\"],\"url\":\"https:\/\/www.redline13.com\/blog\/author\/user\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"File upload with JMeter for Load Testing","description":"How to do a file upload with JMeter. This will then show how the steps when you have a load testing scenario where file upload is required.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/","og_locale":"en_US","og_type":"article","og_title":"File upload with JMeter for Load Testing","og_description":"How to do a file upload with JMeter. This will then show how the steps when you have a load testing scenario where file upload is required.","og_url":"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/","og_site_name":"RedLine13","article_published_time":"2018-08-24T17:57:29+00:00","og_image":[{"width":374,"height":240,"url":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2018\/08\/recording.jpg","type":"image\/jpeg"}],"author":"RedLine13","twitter_card":"summary_large_image","twitter_misc":{"Written by":"RedLine13","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/#article","isPartOf":{"@id":"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/"},"author":{"name":"RedLine13","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/4acbcdcb8a9c72ec5a274e69c0ebea28"},"headline":"File Upload with JMeter","datePublished":"2018-08-24T17:57:29+00:00","dateModified":"2018-08-24T17:57:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/"},"wordCount":453,"publisher":{"@id":"https:\/\/www.redline13.com\/blog\/#organization"},"articleSection":["Blog","JMeter","Load Testing"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/","url":"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/","name":"File upload with JMeter for Load Testing","isPartOf":{"@id":"https:\/\/www.redline13.com\/blog\/#website"},"datePublished":"2018-08-24T17:57:29+00:00","dateModified":"2018-08-24T17:57:29+00:00","description":"How to do a file upload with JMeter. This will then show how the steps when you have a load testing scenario where file upload is required.","breadcrumb":{"@id":"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.redline13.com\/blog\/2018\/08\/file-upload-with-jmeter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.redline13.com\/blog\/"},{"@type":"ListItem","position":2,"name":"File Upload with JMeter"}]},{"@type":"WebSite","@id":"https:\/\/www.redline13.com\/blog\/#website","url":"https:\/\/www.redline13.com\/blog\/","name":"RedLine13","description":"(Almost) Free Load Testing in the Cloud","publisher":{"@id":"https:\/\/www.redline13.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.redline13.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.redline13.com\/blog\/#organization","name":"RedLine13","url":"https:\/\/www.redline13.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg","contentUrl":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg","width":300,"height":68,"caption":"RedLine13"},"image":{"@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/4acbcdcb8a9c72ec5a274e69c0ebea28","name":"RedLine13","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514?s=96&d=mm&r=g","caption":"RedLine13"},"sameAs":["http:\/\/127.0.0.1"],"url":"https:\/\/www.redline13.com\/blog\/author\/user\/"}]}},"_links":{"self":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts\/5136","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/comments?post=5136"}],"version-history":[{"count":0,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts\/5136\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/media\/5144"}],"wp:attachment":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/media?parent=5136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/categories?post=5136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/tags?post=5136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}