【问题标题】:how to read images names form cordova.file.tempDirectory using Ng-Cordova如何使用 Ng-Cordova 从 cordova.file.tempDirectory 中读取图像名称
【发布时间】:2016-08-25 04:21:00
【问题描述】:

我们想使用我们尝试过的文件插件从cordova.file.tempDirectory 读取图像名称

 $cordovaFile.readAsText(cordova.file.tempDirectory)
            .then(function (success) {
                 console.log("success2"+success);
                  }, function (error) {
                      console.log("error"+error);
                  });
But We got error


ERROR: Wrong type for parameter "path" of DirectoryEntry.getFile: Expected String, but got Undefined.
2016-08-25 09:23:28.958 DPOD[3482:38292] Error in Success callbackId: File1548160221 : TypeError: Wrong type for parameter "path" of DirectoryEntry.getFile: Expected String, but got Undefined.

cordova.file.tempDirectory 只有 10 个图像。所以我们需要 10 个图像名称。告诉我我们的代码有什么问题。请指导我们。

【问题讨论】:

    标签: angularjs file cordova ngcordova cordova-plugin-file


    【解决方案1】:

    $cordova.readAsText 接受两个参数 pathfile

    // READ
    $cordovaFile.readAsText(cordova.file.dataDirectory,$scope.inputs.readFile)
      .then(function (success) {
        // success
      }, function (error) {
        // error
      });
    

    尝试将文件作为数组缓冲区读取。在此处查看其他用于读取文件的选项。 ngCordova file plugin

    确保添加 ngCordova 文件和适当的依赖注入。 Installation guide

    【讨论】:

      猜你喜欢
      • 2017-10-17
      • 1970-01-01
      • 2015-11-01
      • 1970-01-01
      • 2020-06-26
      • 2012-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多