Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

cordova-plugin-filepath: Unable to resolve filesystem path in android #38

Open
thisisirfan opened this issue Jan 23, 2019 · 11 comments
Open

Comments

@thisisirfan
Copy link

thisisirfan commented Jan 23, 2019

Trying to upload image from ionic application via android/ios gallery. It's working perfectly fine on ios but throw error in android.
It always throw following error while resolving native path in this.filePath.resolveNativePath(imagePath) method:
{code: 0 ; message: "Unable to resolve filesystem path."}

Here is my code for uploading image:

var options = {
  quality: 60,
  targetWidth:900,
  sourceType: sourceType,
  saveToPhotoAlbum: false,
  correctOrientation: true
};
// Get the data of an image
this.camera.getPicture(options).then((imagePath) => {
  if (this.platform.is('android') && sourceType === this.camera.PictureSourceType.PHOTOLIBRARY) {
    console.log('image path',imagePath)
    this.filePath.resolveNativePath(imagePath)
      .then(res => {
        let correctPath = res.substr(0, res.lastIndexOf('/') + 1).toString();
        let currentName = imagePath.substring(imagePath.lastIndexOf('/') + 1, imagePath.length).toString();
        this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
      }).catch(err=>{
        console.log('unable to resolve file path issue', err)
      });
  } else {
    var currentName = imagePath.substr(imagePath.lastIndexOf('/') + 1);
    var correctPath = imagePath.substr(0, imagePath.lastIndexOf('/') + 1);
    console.log(currentName,correctPath)
    this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
  }
}, (err) => {
  console.log(err);
});

I have even tried using following code but no success:

window.FilePath.resolveNativePath(imagePath)
      .then(res => {
        let correctPath = res.substr(0, res.lastIndexOf('/') + 1).toString();
        let currentName = imagePath.substring(imagePath.lastIndexOf('/') + 1, imagePath.length).toString();
        this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
      }).catch(err=>{
        console.log('unable to resolve file path issue', err)
      });

Here are my plugin details:

<plugin name="cordova-plugin-camera" spec="^4.0.3" />
<plugin name="cordova-plugin-filepath" spec="^1.4.2" />

Ionic info

   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.1
Cordova:
   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.1, (and 15 other plugins)
System:
   Android SDK Tools : 25.2.4
   NodeJS            : v9.11.1
   npm               : 6.0.1 
   OS                : Windows 10
@PeterHdd
Copy link

PeterHdd commented Jan 23, 2019

update filepath plugin to the latest version which is 1.5.1

ionic cordova plugin rm cordova-plugin-filepath
ionic cordova plugin add cordova-plugin-filepath@latest

If that doesn't work then it might be from the ionic webview plugin

@thisisirfan
Copy link
Author

update filepath plugin to the latest version which is 1.5.1

ionic cordova plugin rm cordova-plugin-filepath
ionic cordova plugin add cordova-plugin-filepath@latest

If that doesn't work then it might be from the ionic webview plugin

Thanks for responding, I've already tried with latest version but it still didn't work.

@PeterHdd
Copy link

Alright try the important section and tell me if it works or not.

As im also using the file path plugin to upload files to the server, and it worked with me.

@thisisirfan
Copy link
Author

Alright try the important section and tell me if it works or not.

As im also using the file path plugin to upload files to the server, and it worked with me.

Ok following it

@thisisirfan
Copy link
Author

Alright try the important section and tell me if it works or not.
As im also using the file path plugin to upload files to the server, and it worked with me.

Ok following it

I have followed the https://github.com/PeterHdd/cordova-plugin-crypto-file#important steps and it result encrypt text rather than ionic page.

@thisisirfan
Copy link
Author

Alright try the important section and tell me if it works or not.
As im also using the file path plugin to upload files to the server, and it worked with me.

Ok following it

I have followed the https://github.com/PeterHdd/cordova-plugin-crypto-file#important steps and it result encrypt text rather than ionic page.

Ok i have compiled it again, now app run fine but image upload still return same error:

message: "Unable to resolve filesystem path.

@thisisirfan
Copy link
Author

@PeterHdd It's seems like an android version issue, i just tested in android 5.1 version and it was working perfectly fine but not working on android 8.0 version

@UDTDR
Copy link

UDTDR commented Mar 5, 2019

@PeterHdd It's seems like an android version issue, i just tested in android 5.1 version and it was working perfectly fine but not working on android 8.0 version

Same issue. Anywhere exist a workaround? Thanks

@noveweb
Copy link

noveweb commented Nov 6, 2019

Same here!

@d3v53c
Copy link

d3v53c commented Nov 4, 2020

same issue here..

"cordova-plugin-filepath": "^1.5.8",
"@ionic-native/file-path": "^5.29.0",

Any workarounds yet?

@bhandaribhuminpfizer
Copy link

any solution?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants