[Python] python set-up boundary for POST using multipart/form-data with requests

Discussão em 'Python' iniciado por Stack, Março 14, 2025.

  1. Stack

    Stack Membro Participativo

    I want to send a file using requests but the server works with a fixed boundary set at *****. I'm only able to send a file but the requests module creates a random boundary. How do I overwrite it?

    import requests

    url='http://xxx.xxx.com/uploadfile.php'
    fichier= {'uploadedfile':eek:pen('1103290736_2016_03_23_13_32_55.zip','rb')}
    headers2={'Connection':'Keep-Alive','User-Agent':'Dalvik/1.6.0 (Linux; U; Android 4.4.2; S503+ Build/KOT49H)','Accept-Encoding':'gzip'}
    session= requests.Session()
    session.post(url,headers=headers2,files=fichier)
    session.close()

    Continue reading...

Compartilhe esta Página