科尔多瓦/ PhoneGap的文件传输的插件 [英] Cordova/Phonegap File Transfer plugin
问题描述
我用科尔多瓦/ PhoneGap的,我想用下载的文件的插件,并把它下载文件夹中。我发现这个插件文件传输
http://docs.phonegap.com/en/edge/cordova_file_file.md html的#文件传输
I'm using Cordova/Phonegap and I want to use a plugin for download a file and put it in Downloads folder. I find the plugin FileTransfer http://docs.phonegap.com/en/edge/cordova_file_file.md.html#FileTransfer
我使用这个插件,但我不知道在另一个我想使用设备的本地通知每个设备下载文件夹的路径...我读,我从远程服务器下载文件,但我不t其中是,不显示本机控制台......这是我的code在我的控制器
I'm using this plugin but I don't known the path of folder Download in every device another i want to use the native notification of device...I read that I download the file from remote server but I don't where is and don't show the native console...this is my code in my controller
var fileTransfer = new FileTransfer();
var uri = encodeURI("http://someUrl/tost.pdf");
var fileURL = "/sdcard/Download/tost.pdf";
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("upload error code" + error.code);
},
false,
{
headers: {
//"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
}
}
);
你知道我怎么可以用它与本地通知和正确的路径,我必须下载呢?
Do you know how I can use it with the native notification and the correct path where I must download it?
推荐答案
如果你看一下阿帕奇/科尔多瓦 - 插件文件github上你可以看到你可以读取和写入的位置在适用于iOS,Android和黑莓10。
If you look at the apache/cordova-plugin-file github you can see the locations where you can read from and write to listed in tables for iOS, Android and Blackberry 10.
从它的外观您要下载到Android上的SD卡?正确的URL是这样的:
From the looks of it you are trying to download to a sdcard on Android? The correct url would look like this:
var fileURL = cordova.file.externalRootDirectory+"Download/tost.pdf";
我猜你想要的应用程序开发你的iOS和Android,所以你应该使用这个网址:
I'm guessing you want to develop you app for iOS and Android, so you should use this url:
var fileURL = cordova.file.dataDirectory+"Download/tost.pdf";
因为它是两个有效的URL,它的持久性和私密性。
since it's a valid url on both and it's persistent and private.
这篇关于科尔多瓦/ PhoneGap的文件传输的插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!