Aruna Aruna - 3 months ago 146
AngularJS Question

Cordova file writing throws EACCES (Permission denied) error

I was using

on Ionic mobile application to download some files to Android device which can open with native applications like pdf, word, excel..etc. This plugin was working perfectly before the Marshmallow os update.

It is now throwing
"exception":"/storage/emulated/0/logo_radni.png: open failed: EACCES (Permission denied)"}

in config.xml file I have also added following permissions as well.

<platform name="android">
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
<preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,assets,root" />

This is working on previous android os version. Here is my code sample

angular.module('starter.controllers', ['ionic', 'ngCordova'])
.controller('DashCtrl', function ($scope, $ionicPlatform, $cordovaFileTransfer) {

$scope.downloadFile = function () {
$ionicPlatform.ready(function () {

// File for download
var url = "";

// File name only
var filename = url.split("/").pop();

// Save location
var targetPath = cordova.file.externalRootDirectory + filename;

$, targetPath, {}, true).then(function (result) {
}, function (error) {
}, function (progress) {



I need to download files into
to give access to other applications like pdf readers, word, excel..etc

Plugin References:

Any one have an idea to sort this out?


After the investigation I was able to find the root cause of the issue. This permission issue error is throwing due to the OS Upgrade to Marshmallow. They have changed permission granting procedure. After the API level 23, applications won't get permission at the time of installation. Users have to grant permission at the time of using the Application. So I had to explicitly install a plugin to grant permissions at the time of using device resources.

I have written a quick blog post on this to share with the community. Also thanks @Beat as well :)

Anyone can refer the for quick sample application.

You can find Android API Reference for OS Upgrade permissions here.

Hope this will be helpful for someone else.