JMeter File Upload Download

Source: Internet
Author: User

One, jmeter file upload

 Get ready:

1, JMeter, I use 3.3

2, the interface document, determine the interface address, the way of the request, as well as the necessary parameters and the correct return results

  

 JMeter script:

1. Add a thread group, add an HTTP request under the thread group, and view the result tree

2. The HTTP request fills in the protocol, the server name, the request method, and the path

  

3, because is the upload file, so the parameter must choose "Files Upload" here

  

File name: Fill in the path and name of the file (if you put the file in the bin directory of JMeter, you can write the filename only)

Parameter name: Fill in the parameter name according to the interface document

MIME type: jmeter3.0 can not write, but 3.3 does not write will be error, as long as the written on the line

  To run the script :

  

Upload the file script is OK, can be said to be easy

Second, jmeter file download

  Get ready:

1. Or the JMeter

2. Interface address, I casually find a, my QQ space inside photos, as long as there is a return of the results on the line

JMeter script:

1. Add thread Group, add HTTP request under Thread Group, BeanShell Sampler, view result tree

2.HTTP request, fill in the agreement (do not write or affect), server name, path, request method

  

3. Because the return value in the HTTP request can only be viewed in the response data, we need to save the return data and use the BeanShell

1 ImportJava.io.*;2  3 byte[] result = Prev.getresponsedata ();//This is the data that gets returned to the request, Prev is the return of the last request4  5String file_name = "C:\\users\\jyd\\desktop\\girl.jpg";//represents the location and file name where the files are stored6 7File File =NewFile (file_name);8  9FileOutputStream out =Newfileoutputstream (file);Ten   One out.write (result); A   -Out.close ();

To run the script:

The return result of the HTTP request is the one that can see the returned data

  

It also saves the picture to the desktop

  

Ok!!!

JMeter File Upload Download

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.