Cordova file writing throws EACCES (Permission denied) error
<p>I was using <code>cordova-plugin-file</code> and <code>cordova-plugin-file-transfer</code> 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.</p>

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

<p>in config.xml file I have also added following permissions as well.</p>

<pre><code>&lt;platform name="android"&gt;
   &lt;preference name="AndroidPersistentFileLocation" value="Compatibility" /&gt;
   &lt;preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,assets,root" /&gt;
&lt;/platform&gt;
</code></pre>

<p>This is working on previous android os version. Here is my code sample</p>

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

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

              // File for download
                var url = "http://www.gajotres.net/wp-content/uploads/2015/04/logo_radni.png";

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

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

                $cordovaFileTransfer.download(url, targetPath, {}, true).then(function (result) {
                    console.log('Success');
                }, function (error) {
                    console.log(JSON.stringify(error));
                }, function (progress) {
                    // PROGRESS HANDLING GOES HERE
                });
            });

        };
    })
</code></pre>

<p>Note:</p>

<p>I need to download files into <code>cordova.file.externalRootDirectory</code> to give access to other applications like pdf readers, word, excel..etc</p>

<p>Plugin References:</p>

<p><a href="https://github.com/apache/cordova-plugin-file" rel="nofollow">https://github.com/apache/cordova-plugin-file</a></p>

<p><a href="https://github.com/apache/cordova-plugin-file-transfer" rel="nofollow">https://github.com/apache/cordova-plugin-file-transfer</a></p>

<p><a href="http://ngcordova.com/docs/plugins/fileTransfer/" rel="nofollow">http://ngcordova.com/docs/plugins/fileTransfer/</a></p>

<p>Any one have an idea to sort this out?</p>