dimanche 6 novembre 2016

Ionic / Angular.js- Converting Binary Image Data to Image

In my Ionic App, I have a Laravel webservice that is pulling an image file from AWS S3. The S3 bcuket is secured with an IAM user. Therefore just by simply pointing to the http://S3URL/bucket/imagename.jpg would not work. Instead my API returns a binary stream. I tried converting the binary stream into an image that can be displayed by using the following:

 $scope.receiptdata = response.data; // (response from My web service)
 var basestring = "data:image/png;base64,";
 $scope.newreceipt = basestring + $scope.receiptdata;

And then in my view

However, I received a blank view. I have tested the view with another static image by pointing to a remote url and I know for a fact that it works. Is there a way to display the the image. I am trying not to do away with all the security in my S3 bucket as the images are specific to the users and I don't want other than the user who owns it to own it.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire