1

i am working on image upload in nativescript usign mediafilepicker plugin , but i couldn't resolve the url of image to make preview and send it to server ,

i ve followed some tutorial but it's not working too

 this.mdf.on("getFiles", (res: any) => {
        let results = res.object.get('results');
        results.forEach(element => {
          let millisecondes = (new Date).getTime();
          let folder = fs.knownFolders.documents();
          console.log('folder ',folder);
          let path = fs.path.join(folder.path, millisecondes + ".png");
          // let saved = element.saveFileTo(path, "png")
          this._ngZone.run(() => {
            this.myImg = path;
            console.log('img 1', this.myImg);
          })
        });
      });

this is the outpout of element :

{
   "type": "image",
   "file": "/storage/emulated/0/DCIM/Camera/IMG_20190402_002707.jpg",
   "rawData": {}
 }

and this is the output of folder

 {
   "_path": "/data/user/0/org.nativescript.eportfolio/files",
   "_isKnown": true
 }

but i always get this error

Error in reading bitmap - java.io.FileNotFoundException

i ll be so grateful if any one help , thanks

medfarjallah
  • 43
  • 2
  • 11
  • Your app should acquire read external storage permission in order to read the files on external storage directory, the image path leads to external storage. You will be using [nativescript-permissions](https://github.com/NathanaelA/nativescript-permissions/) plugin for this purpose. – Manoj Apr 27 '19 at 13:45
  • but i ve already did when accessing directory of files and images – medfarjallah Apr 29 '19 at 00:13

0 Answers0