I'm trying to embed an image using the base64 data pattern, instead of a URL reference. I first download the data from Azure Blob storage, using the Azure Node.js SDK:
From what I can tell the data downloads as a string. But I'm not sure what to do with the string to get it into base64.
I need to encode the data as base64 and set the image source attribute. How do I do that?
Here is a snippet that shows what happens when I try to just embed the downloaded data directly:
cameraContainer.listBlobsSegmentedWithPrefix($routeParams.cameraId, path, null, options, function(error, result, response) {
result.entries.forEach(function(entry) {
$http.get(containerUrl + "/" + $routeParams.cameraId + "/" + entry.name + containerToken)
.then(function(successResponse) {
$scope.camera.imageUrl = "data:image/jpeg;base64," + successResponse.data;
}, function(errorResponse) {
});
});
});
I end up getting this error in the browser:
Also, if I try executing the following JS:
console.log(decodeURIComponent(successResponse.data));
I get this error: