In my application i need to be able to capture image in browser then send it back to the server where it gets processed. currently i have a widget that captures an image and returns a pictureUrl for png image.
I'm looking for a best possible way to send it back to server.
Ideally i want this image put back inside the class that I originally fetch from server, then serialize it back to JSON and send to server.
Lets say for instance I heve the following C# class:
myClassWithImage{
Bitmap myBitmap = null;
///many other properties
}
i serialize it to json and send it to the user.
Then i want react to use the instance of this class, update it with the picture, serialize to json & send back updated version. On server I just want to recreate the class instance using Newtonsoft.JSON like:
myClassWithImage imgCl = data.SelectToken("myClassWImage").ToObject<myClassWithImage>();
Is this possible at all? Or should i serialize images to base64 string ans send separately?
UPDATE:
I guess what I'm trying to find out if it is possible to serialize/deserialize the object directly into the instance of class without using additional Base64 string properties to it. If i try to add image Url directly to the myBitmap property I get
Newtonsoft.Json.JsonSerializationException: Newtonsoft.Json.JsonSerializationException: 'Error converting value "data:image/png;base64,....
So should i instead introduce another property to this class to hold the value of the image as string during serialization/deserialization?