0
我花了整整一天的时间来解决这个问题。 文件被下载并存储在设备内存中,而不是未加载的。ngCordova插件zip与dendroid不兼容
// Url of file for download
var url = "http://exapmle/someUrl";
// File names only
var file = "aaa.zip";
$scope.contenutoDownload = function() {
// Save location
var targetPath = cordova.file.dataDirectory + file;
// Use cordovaFileTransfer to store the file in the device storage
$cordovaFileTransfer.download(url + file, targetPath, {}, true).then(function (result) {
console.log('File downloaded. ' + JSON.stringify(result));
$cordovaZip
.unzip(
result.nativeURL,
cordova.file.dataDirectory
).then(function() {
console.log('cordovaZip success');
//Delete zip file
if(cordova.platformId == 'ios') {
$cordovaFile.removeFile(cordova.file.tempDirectory,file);
} else {
$cordovaFile.removeFile(cordova.file.cacheDirectory,file);
}
}, function() {
console.log('cordovaZip error');
}, function (progressEvent) {
console.log(progressEvent);
}
);
}, function (error) {
console.log('Error with cordovaFileTransfer');
}, function (progress) {
$timeout(function() {
$scope.downloadProgress = ((progress.loaded/progress.total) * 100) + '%';
});
});
};
结果总是'cordovaZip错误',如果试图传递任何参数到函数(错误的一个)没有对象返回。