Похоже, я решил это с помощью questions_toolbelt:
from requests_toolbelt import MultipartEncoder
m = MultipartEncoder(
fields = {
"key": "value",
"file1": ("my_file.zip", open("my_file.zip", "rb")),
}
)
def gen():
a = m.read(1024)
while a:
yield a
a = m.read(1024)
r = requests.post(url, data=gen(), headers={'Content-Type': m.content_type})