I have problems trying to store the data of a blob object inside a json object with javascript . This is what happens:
I can recover the object of an image passed through a javascript file (FileReader):
var blob = new Blob([readerImageReal.result], {type: "image/png"});
var img = document.getElementById("attachmentsImg");
img.onload = function () {
drawImage(img); //displays the image in html <img src='blob:...'></img>
};
img.src = window.URL.createObjectURL(file);
But I do not know how to retrieve the blob information to pass it to the server inside a json object . What I'm trying is:
var jsonImages = {};
jsonData['images'] = [];
jsonImages['image_real'] = $('#img').attr('src');
jsonData['images'].push(jsonImages);
But blob src is not the data (it's a uri). How can I store the blob data inside a json object, to send it to a Java server? I want the image with Blob format ( no I want base 64, for example), and I need to extract the data from the browser image.