0

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.

6
  • So basically the proble with your conversion, near converting the binary stream into an image right ? Commented Nov 7, 2016 at 6:15
  • that is correct @Jigar7521 Commented Nov 7, 2016 at 6:18
  • are you using ajax for to retrieve data of image? Commented Nov 7, 2016 at 6:21
  • @Jigar7521- no It is an ionic / angularjs script. I am using http.get to make a rest call to my API server which calls S3 to fetch the file. $file = Storage::disk('s3')->get('filename'); Commented Nov 7, 2016 at 6:25
  • Ok so i think before to get response from your API call, it is not waiting till, and continuing execution ahead, that's why it happening Commented Nov 7, 2016 at 6:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.