2014-11-23 49 views
1

我使用英特爾XDK演示Iframe/URL應用程序來打開網站。但我無法將文件下載到手機本地存儲中。任何人都可以幫助爲什麼發生?英特爾XDK演示URL/Iframe應用程序無法保存/下載文件

我在intel xdk cordova構建中使用此代碼https://github.com/gomobile/sample-url-app/tree/master/www/。當我從網站下載/保存文件到我的android存儲時遇到問題。鏈接下載在瀏覽器中工作,但不在我的應用程序中。給我一個我明白的解決方案,因爲我只是一個初學者。

+0

你能給的你試圖做更詳細一點?一些代碼也會有幫助。你可以嘗試inappbrowser而不是iframe。 – OldGeeksGuide 2014-11-25 23:06:00

+0

我使用此代碼[https://github.com/gomobile/sample-url-app/tree/master/www](https://github.com/gomobile/sample-url-app/tree/master/www )在intel xdk cordova構建中。當我從網站下載/保存文件到我的android存儲時遇到問題。鏈接下載在瀏覽器中工作,但不在我的應用程序中。給我一個我明白的解決方案,因爲我只是一個初學者。 – 2014-11-26 14:26:42

+0

你如何準確下載文件? – OldGeeksGuide 2014-12-03 00:12:31

回答

0

使用英特爾XDK構建的混合應用程序無法在客戶端應用程序上不使用Ajax的情況下從外部網站下載任何內容。您可以使用文件傳輸插件https://github.com/apache/cordova-plugin-file-transfer

示例代碼:

var fileTransfer = new FileTransfer(); 
var uri = encodeURI("http://some.server.com/download.php"); 

fileTransfer.download(
    uri, 
    fileURL, 
    function(entry) { 
     console.log("download complete: " + entry.toURL()); 
    }, 
    function(error) { 
     console.log("download error source " + error.source); 
     console.log("download error target " + error.target); 
     console.log("download error code" + error.code); 
    }, 
    false, 
    { 
     headers: { 
      "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" 
     } 
    } 
); 

文檔https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file-transfer/