java 在 JMeter 中下载和保存文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3464206/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Download and save files in JMeter
提问by Juan P. Osio
Is there any way to configure in JMeter to save the files coming from a response?
In the dialog box, choose 'save file'?
有没有办法在 JMeter 中进行配置以保存来自响应的文件?
在对话框中,选择“保存文件”?
回答by Arti Tripathi
I have been struggling with issue for a week and finally got the solution.
我一直在为这个问题苦苦挣扎一个星期,终于得到了解决方案。
You need to add a Listener "Save response to a file" with that request only that fetches file and then give a location where u want to save the file.
Jmeter saves 2 files one contains response Result and other is the original file.
File format is same as what is fetched from database well in my case the file name that is saved by jmeter on the location is "TEXTFILE_1.octet-stream".
Rename this file to original format like file.jpg or whatever is the format.
You will get the original file and for checking the file integrity, data loss and data corruption, CRC check can be done for the file obtained from jmeter and file before upload - CRC value for the file should be same.
您需要添加一个侦听器“保存对文件的响应”,该请求仅用于获取文件,然后提供您想要保存文件的位置。
Jmeter 保存了 2 个文件,一个包含响应结果,另一个是原始文件。
文件格式与从数据库中获取的内容相同,在我的情况下,jmeter 保存在该位置的文件名是“TEXTFILE_1.octet-stream”。
将此文件重命名为原始格式,如 file.jpg 或任何格式。
您将获得原始文件,为了检查文件完整性、数据丢失和数据损坏,可以对从 jmeter 获取的文件和上传前的文件进行 CRC 检查 - 文件的 CRC 值应相同。
Hope it helps.
希望能帮助到你。
回答by BlackGaff
To retrieve files from the server by clicking the "download" button in your app, in JMETER click the box "download embedded content" OR make your request point directly to the file you are trying to download. You may need to do a regex on the page to get the file location and then create a separate response just for the downloadable file.
要通过单击应用程序中的“下载”按钮从服务器检索文件,请在 JMETER 中单击“下载嵌入内容”框或将请求直接指向您尝试下载的文件。您可能需要在页面上执行正则表达式以获取文件位置,然后仅为可下载文件创建单独的响应。
回答by Rob Hruska
Have you tried using Save Responses to File? If your sampler accesses the URL of the file you're trying to download, it should save the content. I haven't tried it myself, but dialog in this threadseems to indicate that it should work.
您是否尝试过使用Save Responses to File?如果您的采样器访问您尝试下载的文件的 URL,它应该保存内容。我自己还没有尝试过,但是这个线程中的对话框似乎表明它应该可以工作。

