angularjs - View/Stream list of images from s3 in ionic -
we want transfer hosting of images uploaded via mobile aws s3(images not publicly viewed) instead of server local storage. challenge that, how view/stream images in efficient way , limiting memory consumption of mobile phone since sending request aws s3 server give file url.
in documentation, can view image url via s3.getsignedurl , have response of secured url.
var s3 = new aws.s3(); var params = { bucket: 'mybucket', key: 'mypath/image.jpg' }; s3.getsignedurl ('getobject', params, function (err, url) { console.log(url); });
in ionic mobile app, using image-lazy-src efficiently load images without waiting others load. challenge how implement lazy load s3. thinking create directive downloaded/requested image url s3 use image-lazy-src load images. dont know if advisable way since sending consecutive n number of request s3 depends on number of images have in list.
we able find temporary solution or alternative. edited directive image-lazy-src , created new 1 s3 first download aws url , load image-lazy-src image loader.
var s3_url; if ($scope.imagelazybackgroundimage == "true") { var bgimg = new image(); bgimg.onload = function () { if ($attributes.imagelazyloader) { loader.remove(); } $element[0].style.backgroundimage = 'url(' + s3_url + ')'; // set style attribute on element (it load image) if ($scope.lazyscrollresize == "true") { //call resize recalculate size of screen $ionicscrolldelegate.resize(); } }; bgimg.src = s3_url; } else { //download aws image url , assign created image awsservice.generateawsurl('test').then(function(url){ s3_url= url; $element[0].src = s3_url;// set src attribute on element (it load image) },function(error) { console.log(error); }); } }
Comments
Post a Comment