Get the downloaded file name from sampler response in JMeter

Prateek Bhati

I have created a script in JMeter to download a file and now I have to get the name of the downloaded file [filename] from sampler response to store it in a csv file, I have tried to configure the sampler response but it didn't help me out. please see the following

Response headers:
HTTP/1.1 200 OK
Cache-Control: private
Pragma: no-cache
Content-Length: 1235270
Content-Type: application/octet-stream
Expires: Mon, 20 Apr 2015 12:10:35 GMT
Server: Microsoft-IIS/6.0
content-disposition: attachment; **filename="10098_testcase_package.pct**"
Dmitri T

If you need to get "filename" bit from response header you can use Regular Expression Extractor post processor for it

  1. Add Regular Expression Extractor as a child of the request which returns the header
  2. Configure it as follows:

    • Field to check: Response Headers. It matters as by default the Extractor looks up in the response body and you need the header.
    • Reference Name: any variable name, i.e filename
    • Regular Expression: filename="(.+?)"
    • Template: $1$

    Other fileds may be left blank

Regular Expression Extractor

You can refer extracted value as ${filename} where required.

For more information on correlation in JMeter check out Using RegEx (Regular Expression Extractor) with JMeter guide.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to get the thread and the sampler name in JMeter

Jmeter extracting the response value and use on the same HTTP Sampler name

Remove json key from response in jmeter and feed processed response as request to next sampler

How to get the downloaded file name? (Selenium)

How can I set the name for a file that is to be downloaded in a Koa response?

Select random name from the JSON response in JMeter

How to run the same sampler in Jmeter until I get specific result in response data Json

how to check null /empty or value based on response from previous Sampler in Jmeter?

JMETER - WebDriver Sampler - Groovy - Dynamic Name

I want to get ID based on provided name from api response in jmeter

How to get Cookies from response header in jMeter

Get the dynamic ID from the response page in Jmeter

wget: downloaded file name

HttpURLConnection downloaded file name

Get error when run WebDriver Sampler in jmeter

JMeter jp@gc-WebDriver Sampler — Run the Webpage from CSV File

Why the BAT file launched from JMeter OS Sampler is not triggering the Maven execution?

JMeter - How to extract values from a response which has been decoded from base64 and stored in a variable? All under the same sampler

Call function from different sampler in JMeter - Groovy

How to get Sampler Body data from beanshell Pre-Processor - JMeter

How to replace downloaded image with same file name in storage from server?

Change name of audio file downloaded from youtube-dl

JMeter Groovy - WebDriver Sampler script failed with Response Code 500

How do I override the response content in a JMeter WebDriver sampler test?

How to get the kernel version name from downloaded Ubuntu ISO

How to make Jmeter run command from CMD - OS sampler - JMETER

JMeter jp@gc-WebDriver Sampler Element Name is dynamic

Get response size (and other variables) in an external file with JMeter

Headless JMeter -How to get printed the response data in the output file