I have two applications (one in Python and another in Java). They are connected via XML-RPC protocol. I have image files saved in database as binary data and i need to get them in Java.
So i make a query to get the data in python and i return a dictionary as you can see below:
aux = {
'location_id' : location['id'],
'name' : location['name'] or " ",
'units' : location['units'] or 0.0,
'area' : location['area'] or 0.0,
'day_meter' : location['day_meter'] or 0.0,
'free' : location['free'] or 0.0,
'type' : location['type'] or " ",
'loc_type' : location['loc_type'] or " ",
'image' : str(location['image']),
}
I receive the data without problems in Java but i can not get the image file from the binary data. Here is my code:
I make a cast to convert the binaty data to a byte [] in Java
byte[] b = aux.get("image").toString().getBytes("UTF-8");
l.setByteImg(b);
And here i try to construct a BufferedImage.
InputStream in = new ByteArrayInputStream(l.getByteImg());
BufferedImage bImageFromConvert = ImageIO.read(in);
But i get a null in my bImageFromConvert.
What am i doing wrong??