【发布时间】:2017-10-21 17:38:32
【问题描述】:
在使用cordova plugin file transfer时,下载文件成功,但没有显示在任何地方,代码添加如下:
var onGetDirectorySuccess = function(fileEntry) {
downloadpostnow(fileEntry, 'http://50.63.14.130/Images/OrderProof/Plugd7a09191-7cdd-4f21-babd-041e3f914ebb.MOV');
}
var onGetDirectoryFail = function(error) {
showError("There is an error while processing your download.",0);
return false;
}
var onRequestFileSystemSuccess = function(fileSystem) {
var entry=fileSystem.root;
entry.getDirectory("plug", {create: true, exclusive: false}, onGetDirectorySuccess, onGetDirectoryFail);
}
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onRequestFileSystemSuccess, null);
function downloadpostnow(fileEntry, uri){
var fileTransfer = new FileTransfer();
var fileURL = fileEntry.toURL();
var uri = encodeURI(uri);
var uriname = uri.split("/");
uriname = uriname[uriname.length-1];
fileTransfer.download(
uri,
fileURL+uriname,
function (entry) {
alert(JSON.stringify(entry));
//showError("Download Completed.",1);
fileTransfer.abort();
},
function (error) {
fileTransfer.abort();
//showError("There is an error while downloading your post.",0);
return false;
},
true,
{/**/}
);
}
使用此功能,文件下载完成,IOS不显示
【问题讨论】:
-
存储在文档目录中。可以分享下载视频的路径吗?你可以使用 fileURL 。
-
file://var/mobile/Containers/Data/Application/some_id/Documents/plug/Plugd7a09191-7cdd-4f21-babd-041e3f914ebb.MOV
-
您能说明一下您想在 iOS 的哪个位置观看视频吗?