jmeter与python上传文件方式
MIME类型可根据抓包进行调整multipart/form-data;文件名称可进行参数化
备注:
最近在做上传文件接口时,postman可以调通,但是jmeter一直不通,抓包比较了两种调用方式后,jmeter上传文件提示:failed to decode multipart body,尝试了各种方式,最后在网上找到了解决方式,删除header中的Content-Type
参考链接:https://www.pianshen.com/article/53921634810/
---------------------------------------------python上传图片-----------------------------------------------------
import requests import pandas as pd import json import time from datetime import datetime import threading import random import sys import os def send_post_image_nsfw(img_path): """ :param img: :return: """ files={ 'img_path':open(img_path, 'rb').read() } params = { } html = requests.post(url = 'xxxxxxxxx', files=files, params=params).text print(html) return html if __name__ == '__main__': file = 'E:\\6a3b6cf10e3fd4427d1f581f7ec2a2fb.jpg' send_post_image_nsfw(file)