Make post request in python by sending a base64 image

0
Hello, I am studying python and I am trying to create a post in python that receives an image, saves it to the computer and sends it to an external service through a request.post.

 aux = imagem.read().encode("base64")
 files = {'file':aux}
 headers = {'content-type': 'multipart/form-data'}
     r = requests.post(url, files=files, headers=headers)

The conversion to base64 is working already checked by doing the reverse of the file. The question is in the request because for some reason the information that arrives on the server is in different form.

For example before the request:

 files = {'file':'/9j/4AAQSkZJ....'}

But by printing what resquest sends I actually realized that base64 is different:

  files = {'file':'%2f9....'}

For this reason I get an error message

 {
  "response": "Error. Make a POST request with a single field called 'file' containing a base64.",
  "success": "false"
 }

This service I am using is working normally, I tested using Postman

Python 2.7.15rc1 and Flask

Does anyone know what's going on? Thank you in advance.

    
asked by anonymous 28.09.2018 / 23:39

0 answers