JSFiddle - React, Tailwind, and code Playground

by anil001ry

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/aws-sdk/2.2.9/aws-sdk.min.js"></script>
<section ng-app data-ng-controller="myCtrl">
    <img  ng-src="{{s3url}}" id="myimg">
</section>

JavaScript

function myCtrl($scope, $timeout) {
  AWS.config.update({
    accessKeyId: 'll',
    secretAccessKey: 'll'
  });
  AWS.config.region = "ll";

  var bucket = new AWS.S3({
    params: {
      Bucket: 'isl-ardemo-s3'
    }
  });

  bucket.getObject({
    Key: 'mv.jpg'
  }, function(err, file) {

    $timeout(function() {
      $scope.s3url = "data:image/jpeg;base64," + encode(file.Body);
    }, 1);
  });
}

function encode(data) {
  var str = data.reduce(function(a, b) {
    return a + String.fromCharCode(b)
  }, '');
  return btoa(str).replace(/.{76}(?=.)/g, '$&\n');
}