Iro*_*nic 5 android phonegap-plugins cordova
在开始之前,我尝试了以下来自堆栈溢出的答案。
使用phonegap将文件下载到ios/android下载文件夹
使用 Cordova FileTransfer 将文件下载到设备的下载文件夹
http://www.phonegaptutorial.com/downloading-an-image-from-the-internet-with-phonegap/
但一点运气都没有。
我正在尝试从互联网下载文件。我的目标是下载 Android 手机上下载文件夹中的文件。
我尝试了上述所有答案,而且我还使用了科尔多瓦网站上的科尔多瓦示例。
https://cordova.apache.org/docs/en/2.0.0/cordova/file/filetransfer/filetransfer.html
function downloadCL(){
var url = "http://www.phonegaptutorial.com/wp-content/uploads/examples/phonegap-logo.png";
// we need to access LocalFileSystem
window.requestFileSystem(window.LocalFileSystem.PERSISTENT, 0, function(fs)
{
// create the download directory is doesn't exist
fs.root.getDirectory('downloads', { create: true });
// we will save file in .. downloads/phonegap-logo.png
var filePath = fs.root.fullPath + '/downloads/' + url.split('/').pop();
var fileTransfer = new window.FileTransfer();
var uri = encodeURI(decodeURIComponent(url));
fileTransfer.download(uri, filePath, function(entry)
{
alert("Successfully downloaded file, full path is " + entry.fullPath);
},
function(error)
{
console.log("Some error " + error.code + " for " + url +);
},
false);
}
};
};
Run Code Online (Sandbox Code Playgroud)
任何建议如何实现这一目标。
Fork,
您必须选择下载文件网址,
本地下载文件位于此处 -
file:///storage/emulated/0/download 此链接可能会帮助您 -
添加了可供下载的文件传输插件,例如 -
https://github.com/cfjedimaster/Cordova-Examples/tree/master/asyncdownload
根据要求选择任何一个
| 归档时间: |
|
| 查看次数: |
15859 次 |
| 最近记录: |