In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the method of Jmeter test uploading picture base64 coding interface". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Jmeter test upload picture base64 coding interface is what" bar!
Recently, I encountered a project in which there are fields in the API that need to upload images, which are passed in the form of base64 encoding of images. (Base64 is currently mainly used in scenarios where IE6 is not considered, such as HTML5 and mobile development. ) an example of a request message is as follows:
Questions about how to test the implementation:
1) how to encode a picture?
2) in order to realize the interface automatic test, how to realize the automatic base64 coding
Solution:
Method 1: use the picture online transcoding base64 coding website to encode.
Coding website: http://tool.css-js.com/base64.html
To upload local images, check the options such as "include headers" as needed to generate the base64 encoding of the images.
Disadvantages: when testing different pictures, it needs to be coded manually, and then copied and encoded into the interface request message, which can not be automated and the testing efficiency is low.
Method 2: use the beanshell of Jmeter to write the conversion code of picture base64 coding.
1) write base64 coding code for pictures
In general, the developer will provide the code; if not, don't be afraid, Baidu can do it, or students with code skills can write it themselves. Some of the codes are as follows:
2) generate the jar package and place it in the ${JMETER_HOME}\ lib\ ext directory
3) write beanshell and call the coding method to encode
4) parameterized request message
Actual request message:
This method solves the problem of manual picture base64 coding and provides support for subsequent automated testing.
Extension: what if the uploaded picture is not in base64-encoded format, that is, sending a request message in the form of an image file?
Solution: take advantage of the "send file with request" function in jmeter's sampler
A. Click the add button in the "send File with request" column.
B. Click the browse button to select a picture to be uploaded, and the address will be automatically recorded in the file name column.
C. Fill in the parameter name, here is [image]
D, MIME type is multipart/form-data
(note: another setting is > in order to upload files, you must also check "Use multipart/form-data for POST", and then the MIME type can be filled in according to the actual situation, otherwise request will not contain the uploaded files. )
Save the HTTP request, execute it, and check the server to find that the image selected in the above step has been successfully uploaded to the server. If you want to parameterize the image, you only need to parameterize the path of the picture.
At this point, I believe that everyone on the "Jmeter test upload picture base64 coding interface is what" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.