Uploading an image

Hi Wagner,


I want to upload an image to a XData server to store in a database from a native Android app.  I'm converting the image to Base64 before putting it in the JSON object and uploading it.  It's getting into the database okay but I don't know how to use it once it's in the database.  What I mean is I can't figure out what format it's stored in the database.  I tried just saving the data from the database to a file with a .jpg extension but it's not readable.  I've also tried using TNetEncoding.Base64.Decode from Delphi but that doesn't work either. Could you give me a pointer in the right direction please?

Regards

Steve Sinclair

Hi Steve,

A blob in database has no "format". It just has a bunch of bytes. Whatever bytes you encoded as base64 will be there in the database field. Maybe the problem is in the data you are encoding to base64? It's hard to tell what's going on, maybe you could provide more details for the whole process (since the Android).

In theory, all you need to do is indeed put the data encoded in base64 in a JSON property representing an entity, it will be correctly saved in the database.