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() 
  • What does "server does not perceive"? The code you gave is correct and requests will successfully create a multipart/form-data request. - m9_psy
  • vk api incorrectly perceives - user231814
  • one
    This is clearly not enough, give an example of your code on the server - sending is OK. - m9_psy

0