FileTransfer Cordova download path
<p>I'm using Cordova (5.4) to create apps for Android and Iphone. All goes fine, except I want to download images using the Cordova's plugin "<a href="https://github.com/apache/cordova-plugin-file-transfer" rel="nofollow">FileTransfer</a>" and I having some problems with the path.</p>

<p>If I use the FileTransfer like this:</p>

<pre><code>       uri = encodeURI('http://example.com/myImage.png'),
            fileURL = '/sdcard/Download/' + 'myImage.png',
fileTransfer.download(
                uri,
                fileURL,
                function (entry) {
                    console.log("download complete: " + entry.fullPath);
                },
                function (error) {
                    console.log(error);
                },
                false,
                {
                    headers: {
                        "authorization": 'Bearer ' + token
                    }
                }
            );
</code></pre>

<p>This works fine. But I would want a path that worked on Android and Iphone, (not a static one) and if it could be, that the user could see this images directly in their gallery.</p>

<p>Checking the plugin description I tried:</p>

<pre><code>fileURL = 'cdvfile://localhost/persistent/myImg.png'
</code></pre>

<p>But this fails with the FileTrasferError:</p>

<blockquote>
  <p>"/data/data/com.aco.plus/files/files/myImg.png: open failed: ENOTDIR (Not a directory)"</p>
</blockquote>

<p>Checking answers around I tried also:</p>

<pre><code>uri = encodeURI('http://example.com/myImage.png');

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {

            fileTransfer.download(
                uri,
                fileSystem.root.toURL() + '/' + 'myImg.png',
                function (entry) {
                    console.log("download complete: " + entry.fullPath);
                },
                function (error) {
                    console.log(error);

                },
                false,
                {
                    headers: {
                        "authorization": 'Bearer ' + token
                    }
                }
            );
        });
</code></pre>

<p>And I got the same error.</p>

<p>I'm quite lost. Anyone knows what can I do? I'm quite sure that must be a better way to do it than static routes.</p>