Python3 flask receive file and send it to another api Python3 flask receive file and send it to another api flask flask

Python3 flask receive file and send it to another api


I got code:400 as return or it shows the file I upload is empty, I found requests in flask is a little bit tricky.change this

r1 = requests.request("POST", url1, files={'file':request.files['file']}, headers=headers)

into:

file = request.files['file']r1 = requests.post(url1, files={'file':(file.filename, file.stream, file.content_type, file.headers)})