There is a function that draws a graph using matplotlib and creates a plt object. Then I save the bytes of the image in the buf , and after that I try to upload them to the server. (The code is below)
The problem is that for some reason the server does not accept these bytes, although I did buf.seek , and if this buffer is saved to a file (ie, make open('1.png', 'wb').write(buf.getvalue()) everything is saved.)
buf = io.BytesIO() plt.savefig(buf, format='png') buf.seek(0) picture = {'photo': buf.getvalue()} req = requests.post(url, files=picture) buf.close()
requestswill successfully create amultipart/form-datarequest. - m9_psy