Skip to content Skip to sidebar Skip to footer

How Can I Get Images From Local Storage And Then Display Them On Screen In Native Script. I Am Using Nativescript-imagepicker And Fs

I am new to Native Script. How can I display an image from local storage? I used the nativescript-imagepicker but then, I don't know where the image is stored. I am using this code

Solution 1:

var context = imagepickerModule.create({
    mode: "single" // allow choosing single image
});
context
    .authorize()
    .then(function () {
        return context.present();
    })
    .then(function (selection) {
        console.log("Selection done:");
        setTimeout(() => {
            selection.forEach(function (selected) {
                selected.getImage().then((source) => {
                    console.log(selected.fileUri); // this is the uri you need
                });     
            });
        }, 1000);            
    }).catch(function (e) {
        console.log(e);
    });

Use the fileUri. And that setTimeout is optional, in my project without that, the app screen was going blank for a second.


Post a Comment for "How Can I Get Images From Local Storage And Then Display Them On Screen In Native Script. I Am Using Nativescript-imagepicker And Fs"