I have installed the plugin but I am unable to download the file.
It is showing logs in android as file is downloaded but it is not getting downloaded
Please Help…
.controller('PlaylistsCtrl', function($scope, $timeout, $cordovaFileTransfer, $ionicPlatform) {
$scope.downloadFile = function () {
var permissions = cordova.plugins.permissions;
permissions.hasPermission(permissions.READ_EXTERNAL_STORAGE, checkPermissionCallback, null);
function checkPermissionCallback(status) {
if (!status.hasPermission) {
var errorCallback = function () {
console.warn('Storage permission is not turned on');
}
permissions.requestPermission(
permissions.READ_EXTERNAL_STORAGE,
function (status) {
if (!status.hasPermission) {
errorCallback();
} else {
// continue with downloading/ Accessing operation
$scope.downloadFile();
}
},
errorCallback);
}
}
$ionicPlatform.ready(function () {
var url = "http://cdn.wall-pix.net/albums/art-space/00030109.jpg";
var filename = url.split("/").pop();
var targetPath = cordova.file.externalRootDirectory + 'Download/' + filename;
var trustHosts = true;
var options = {};
$cordovaFileTransfer.download(url, targetPath, options, trustHosts)
.then(function (result) {
console.log('Success');
$scope.hasil = 'Save file on ' + targetPath + ' success!';
}, function (err) {
console.log(cordova.file.externalRootDirectory);
$scope.hasil = 'Error downloading file...';
}, function (progress) {
$timeout(function () {
$scope.downloadProgress = (progress.loaded / progress.total) * 100;
});
});
});
};
})