使用ionic和cordova在iOS上无效的文件传输错误

时间:2017-11-30 10:02:23

标签: javascript ios cordova typescript ionic-framework

我正在使用cordova文件传输插件将文件下载到用户设备,它在Android上运行罚款。但是在ios上,文件无法下载,它会在日志中抛出此错误

File Transfer Error: Invalid server URL http://sampleweb.com/img/1.jpg

但我正在使用的相同代码适用于Android设备

downloadImage() {

    this.platform.ready().then(() => {
      const fileTransfer: FileTransferObject = this.Transfer.create();
      const audiolocation = `http://sampleweb.com/audio/1.mp3`


    fileTransfer.onProgress((progress) => {
      this.total = progress.total;
      this.loaded = progress.loaded;
      //setInterval(() => {
      this.percentage = Math.round((progress.loaded / progress.total) * 100);
      console.log(this.percentage);

    })
      fileTransfer.download(audiolocation, this.storageDirectory+'myapp/'+this.audio_download).then((entry) => {
        const alertSuccess = this.alertCtrl.create({
          title: `Download Succeeded!`,
          subTitle: `Audio has been successfully downloaded`,
          buttons: ['Ok']
        });

        console.log(audiolocation)
      }, (error) => {
        const alertFailure = this.alertCtrl.create({
          title: `Download Failed!`,
          subTitle: `Download Failed. Error code: ${error.code}`,
          buttons: ['Ok']
        });

        alertFailure.present();
      });

    });

  }

0 个答案:

没有答案