【问题标题】:Ionic Cordova resolveNativePath error - Unable to resolve filesystem pathIonic Cordova resolveNativePath 错误 - 无法解析文件系统路径
【发布时间】:2022-07-22 20:15:48
【问题描述】:

我正在尝试在 android 中上传 PDF 文件。

我正在使用 @awesome-cordova-plugins/chooser/ngx 从 chooser.getFile("application/PDF") 获取内容 URI。

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

需要将其转换为文件路径,以便我可以使用 fileTransfer.upload() 函数通过 @awesome-cordova-plugins/file-path 上传文件

但不幸的是 FilePath.resolveNativePath 给出了以下错误{code: 0, message: 'Unable to resolve filesystem path.'} 对于 FilePath,我使用 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 库

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


Cordova 插件

        "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",

其他版本详情

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

【问题讨论】:

  • 不幸的是,作者声明该插件不再维护。
  • 这个问题有什么解决办法吗?
  • 很遗憾没有。使用 dataURI 而不是 URI 实现,它以 base64 格式获取文档。

标签: android angular cordova ionic-framework


【解决方案1】:

我也面临同样的问题。你能分享一下你的修复方法吗?

谢谢

【讨论】:

猜你喜欢
  • 2011-02-12
  • 2016-02-12
  • 2017-10-17
  • 2015-12-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多