我使用最新版本1.6.2 cordova-plugin-file-transfer android 6.0获取错误代码1

时间:2017-04-24 15:35:26

标签: android cordova cordova-plugins

大家好,我有这个代码,并在android 4和android 6.0文件传输版本1.6.1工作,直到更新上一版本1.6.2 cordova-plugin-file-transfer,而不是在android 6.0中工作。但在android 4.0工作,我更改localPath =“cdvfile:// localhost / persistent并添加config.xml访问origin =”cdvfile:// *“但是还没有工作,我不知道是什么问题,apreciate您的帮助或任何示例

function download() {

var downloadUrl = "http://url/001.jpg";
var relativeFilePath = "001/001.jpg";  // using an absolute path also does not work
var directorio = cordova.file.externalRootDirectory + relativeFilePath;
window.directorio = directorio;

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
   var fileTransfer = new FileTransfer();
   fileTransfer.download(
      downloadUrl,

      // The correct path!
       fileSystem.root.toURL() + '/' + relativeFilePath,
       ///localPath = "cdvfile://localhost/persistent/001/001.jpg", // I test with this a get the same error code 1

      function (entry) {
open();
        // console.log("Success");
      },
      function (error) {
   alert("An error has occurred: Code = " + error.code);

      }
   );
});

0 个答案:

没有答案