Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49186

How to set downloaded image from AWS as an image via ng-src

$
0
0

@Kawahara wrote:

Hello everyone!
So I've been writing an app, which downloads images from AWS and sets it in the view, as

The code I am using is below:
function DownloadImages($localstorage, $cordovaFile, $ionicPlatform, $ionicLoading) {
var vm = this;
var test = {};

    vm.createDirectoryForImages = function (directory) {
        $ionicPlatform.ready(function () {
        }).then(function () {
            $cordovaFile.createDir(cordova.file.dataDirectory, directory, true)
                .then(function (entry) {

                }, function (error) {
                    alert("Could not create directory: " + error.status);
                })
        });
    };

    vm.download = function (directory, filename) {
        $ionicLoading.show({
            template: '<ion-spinner icon="spiral"></ion-spinner> </br>Downloading...'
        });
        var hike = JSON.parse($localstorage.get("hikelistandinformation"));
        var url = hike.photosUrl + "1.png";
        vm.createDirectoryForImages(directory);
        $ionicPlatform.ready(function() {
        }).then(function() {
            var ft = new FileTransfer();
            ft.download(url, cordova.file.dataDirectory + directory + "/" + filename, function successfullyDownloaded(entry) {
                return entry.toURL();
                $ionicLoading.hide();
            }, function error(error) {
                $ionicLoading.hide();
                alert("Download error: " + error);
            }, true, {});
        });


        //fileTransfer.download(url, cordova.file.dataDirectory + "LanikaiPillbox")
    };
}

However, whenever I try to set the image source as the entry url, nothing appears on the view. I have tried toInternalURL(), and fullPath(), but nothing seems to work.

Any advice would be greatly appreciated! Thanks in advance!

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>