在postman 中 可通过二进制数据流方式上传图片,如下所示:
![](https://img2020.cnblogs.com/blog/1193459/202109/1193459-20210910164302286-267999288.png)
![](https://img2020.cnblogs.com/blog/1193459/202109/1193459-20210910164351487-807955276.png)
headers 中添加 uid ,filename ;
body 中选择 binary ,然后上传图片;
但是,通过性能压测 postman 就不可以了,所以我通过LoadRunner 编辑脚本如下,
注意:图片文件名要一致;
lr_start_transaction("图片上传"); //开始事务
web_add_header("uid","00520030-3030510b-37323537"); web_add_header("filename","/photo/1631288908.jpg"); //图片文件名
// web_add_header("Content–Type", // "multipart/form–data;boundary=–––––––––––––––––––––––––––292742461228954");
web_custom_request("web_custom_request", "URL=http://xx.xx.169.75:45002/xxxxxxxx/devicePhoto/upload", "Method=POST", "Resource=0", "RecContentType=image/jpeg", "Referer=", "Snapshot=t2.inf", "Mode=HTML", "EncType=application/json",//类型 // "EncType=application/x-www-form-urlencoded", "BodyFIlePath=D:\tu\1631288908.jpg",//二进制文件 //图片文件名 LAST); lr_end_transaction("图片上传",LR_AUTO); // 结束事务
return 0;
|
-------End-------