如何使用参数发送文件而不是在JMeter HTTP Request Sampler中的FilePath中设置?

时间:2016-04-11 21:53:41

标签: jmeter http-post jmeter-plugins

当我使用bean shell脚本将文件预加载到变量然后 将它设置在HTTP请求采样器的参数中以上传文件,从wireshark数据包中我发现内容长度不正确。 内容类型也设置为text / plain,这会导致问题。 我怎样才能改变它?

以下是一些显示jemter设置和wireshrak监听的图片。

The wireshark snoop when the content of the file set as the value of the parameter of the Http request sampler The jmeter test element setup showing that the the content of the file is set in the http request parameter

1 个答案:

答案 0 :(得分:1)

您使用了错误的配置:

  1. 检查Use multipart/form-data for POST
  2. Parameters区域
  3. 中删除您的文件
  4. 将其添加到Send Files With the Request区域,如:

    • 文件路径:${__property(FileData,,)}
    • 参数名称:File
    • MIME类型:text/plain

      Example upload configuration

  5. 有关在JMeter脚本中模拟文件上载和下载事件的详细信息,请参阅Performance testing: Upload and Download Scenarios with Apache JMeter指南。