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)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM