I tell you, I have the following problem:
I have a WebService in C # where one of the parameters that I have to pass is a string (the image converted to base64string)
I really do not know why the base64 string is not being stored correctly.
Since when displaying the image in a grid view. it looks like this: (the symbol when the image is not correct or can not be read)
import base64
import datetime
import requests
from print_utils import *
#DATETIME
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
#BASE64
image = open('ddd.jpg', 'rb')
image_read = image.read()
image_64_encode = base64.encodestring(image_read)
request_body = 'IdUsuario={id}&Temperatura={temp}&Humedad={hum}&Imagen={img}&fecha={fech}'.format(id='1', temp='20', hum='18', img=image_64_encode, fech=now)
request_headers = {'Host': 'localhost',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
response = requests.post('http://localhost:13600/Servicio.asmx/InsertarMedicion',
data=request_body, headers=request_headers)
request = response.request
The logic tells me that it is a problem related to the POST request. Since using exactly the same conversion used, but replacing POST with the pyodbc driver to make the direct connection to the database. The image ends up showing perfect in the grid view.