【问题标题】:Converting image to base64 in Jmeter在 Jmeter 中将图像转换为 base64
【发布时间】:2020-08-26 02:26:20
【问题描述】:

我是 Jmeter 新手,需要一些指导。我正在尝试从目录中读取大量图像,并且需要在 Jmeter 中将每张图片转换为 base64。如果我理解正确,在 HTTP 请求中我可以使用 __FileToString。但是,我需要先转换它然后传递给请求。 我曾尝试使用 ForController 并按照 Internet 上的说明使用 BeanShell Sampler 进行转换,但图像出现损坏。你能指导我怎么做吗?谢谢。

【问题讨论】:

    标签: jmeter base64 beanshell


    【解决方案1】:

    我听说过Groovy is the new black,还有you should not be using Beanshell since JMeter 3.1

    因此,您可以使用 __groovy() function 将图像转换为其 Base64 表示形式:

    ${__groovy(new File('/path/to/your/image.png').bytes.encodeBase64().toString(),)}
    

    【讨论】:

      猜你喜欢
      • 2015-12-09
      • 1970-01-01
      • 1970-01-01
      • 2014-04-06
      • 2017-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多