Display image from internal storage in Vue + Cordova

131 Views Asked by At

I am trying to display an image from download folder.

imagePath: file:///storage/emulated/0/Download/sample.png

Set Image URL:

window.resolveLocalFileSystemURL(this.imagePath, function success(fileEntry) {
            fileEntry.file(function (file) {
                var reader = new FileReader();
                reader.onloadend = function() {
                    if (this.result) {
                        var blob = new Blob([new Uint8Array(this.result)], { type: "image/png" });
                        this.imgUrl = window.URL.createObjectURL(blob);
                    }
                };
                reader.readAsArrayBuffer(file);
            });
        }, function (err) {
            this.info = 'An error was found: '+ err;
        });

Display it on UI:

<img class="img-fluid" src="{{imgUrl}}" />

But code is not reaching inside onloadend callback.

0

There are 0 best solutions below