2017-06-09 2 views
0

私のionic-2-appにファイルをダウンロードしたい。私は以下のスクリプトとイオンネイティブ転送プラグインを使用します。イオン2ダウンロードファイルからのファイル/転送エラーコード1

let headers = new Headers(); 
    headers.append('TOKEN-NAME', storedtoken); 

    let url = storedendpoint.apiendpoint + 'path/to/api/force/download/file'; 

    File.resolveLocalFilesystemUrl(cordova.file.applicationStorageDirectory).then((dirEntry) => { 

    console.log('resolveLocalFilesystemUrl: ', dirEntry); 

    this.transfer.download(encodeURI(url), dirEntry.nativeURL + filename, true, {headers: headers}) 
      .then((entry) => { 
       console.log('Transfer: ', entry); 
      }, (error) => { 
       console.log('Transfer Error: ', error); 
      }) 

    }); 

をしかし、私は次のエラーを取得する:

body: "Could not create target file"

code: 1

exception: null

http_status: 200

source: " http://domain/apiendpoint/api/path/to/api/force/download/file "

target: "file:////var/mobile/Containers/Data/Application/XXXXX-YYYYY-WWWW-1234-DSFR45RFDT65T/filename.doc"

私はブラウザでそれをしようとするとダウンロードが完璧に動作します。

答えて

0

okが、問題を発見:

cordova.file.applicationStorageDirectory 

は読み取り専用です。それはで動作します

cordova.file.cacheDirectory 
関連する問題