jmeter - 在 Jmeter 中将图像转换为 base64
问题描述
我是 Jmeter 的新手,需要一些指导。我正在尝试从目录中读取大量图像,并且需要在 Jmeter 中将每张图片转换为 base64。如果我理解正确,我可以在 HTTP 请求中使用 __FileToString。但是,我需要先转换它然后传递给请求。我曾尝试使用 ForController 并按照 Internet 上的说明使用 BeanShell Sampler 进行转换,但图像出现损坏。你能指导我怎么做吗?谢谢。
解决方案
I've heard Groovy is the new black, moreover you should not be using Beanshell since JMeter 3.1
So you can convert an image into its Base64 representation using __groovy() function like:
${__groovy(new File('/path/to/your/image.png').bytes.encodeBase64().toString(),)}
推荐阅读
- c++ - 有没有办法删除结构数组的一个元素?
- oracle - 如何知道谁以及如何在 Oracle 自治事务处理中使用了预定义的数据库服务名称
- asp.net-core-mvc - 身份服务器 4 loclaAPi 频繁报错:响应状态码不表示成功:503(服务器已关闭)
- javascript - 应该为点赞按钮使用哪种 HTTP 请求方法
- java - java的compareTo()函数中的字符层次结构
- python - 无法使用 seaborn 绘制双轴
- terraform - 在 terragrunt 配置之间共享 aws_route53_record?
- laravel - 从 Vue 发布到 Laravel 时,Laravel 重定向不起作用
- python - 使用 scipy.optimize 中的 curve_fit 拟合数据后,如何确定某个 x 处的 y_predicted?
- angular - 根据另一个值验证一个角度反应形式的输入字段