Ionic Cordova resolveNativePath error - Unable to resolve filesystem path

Viewed 370

I am trying to upload a PDF file in android.

I am getting content URI from chooser.getFile("application/PDF") using @awesome-cordova-plugins/chooser/ngx.

"content://com.android.providers.media.documents/document/document%3A26"

which needs to be converted to a file path so that I can use the fileTransfer.upload() function to upload the file using @awesome-cordova-plugins/file-path

But unfortunately FilePath.resolveNativePath gives the following error {code: 0, message: 'Unable to resolve filesystem path.'} For FilePath, I am using import { FilePath } from '@awesome-cordova-plugins/file-path';

  choosePDFFiles() {
    this.chooser
      .getFile("application/PDF")
      .then(async (file) => {
        FilePath.resolveNativePath(file.uri)
        .then(async (rfile) => {
          let x =  JSON.parse(await (await this.fileTransferService.upload(encodeURI(rfile), 'profileCertifications','application/pdf')).response);
          console.log(x);
          
        })
        .catch((err) => {
          console.log(err);
    });

Npm Libraries used

        "@ionic-native/file-transfer": "^5.33.1",
        "@ionic-native/file-chooser": "^5.36.0",
        "@awesome-cordova-plugins/chooser": "^5.39.1",


Cordova plugins

        "cordova-plugin-filepath": "^1.6.0",
        "cordova-plugin-chooser": "^1.3.2",
        "cordova-plugin-file-transfer": "git+https://github.com/apache/cordova-plugin-file-transfer.git",
        "cordova-plugin-file": "^6.0.2",

Other version details

 Ionic CLI                     : 6.17.0
 Ionic Framework               : @ionic/angular 6.0.12
 Cordova CLI       : 10.0.0
 Cordova Platforms : android 10.1.1
0 Answers
Related