Home Cordova file-transfer says download complete but file is not actually there
Reply: 0

Cordova file-transfer says download complete but file is not actually there

user2184
1#
user2184 Published in April 26, 2018, 5:28 pm

Running cordova on iOS and Android platforms. Testing file-transfer on Android first, as depicted below:

var file_url = "http://example.com/download.php" // there is a real url in my app
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs)
{
    console.log('file system open: ' + fs.name);
    fs.root.getFile("Test.pdf",{create:true, exclusive:false}, 
    function(fileEntry)
    {
        console.log("fileEntry is file?" + fileEntry.isFile.toString());
        if(fileEntry.isFile) 
        {
            console.log(fileEntry.toURL());
            var fileTransfer = new FileTransfer();
            var uri = encodeURI(file_url);
            fileTransfer.download
            (
                uri,
                fileEntry.toURL(),
                function(entry)
                {
                    console.log("download complete: " + entry.toURL());
                },
                function(error)
                {
                    console.log("download error source " + error.source);
                    console.log("download error target " + error.target);
                    console.log("download error code" + error.code);
                },
                false
            );
        }
        else console.log('Not file somehow?');
    }, function()
    {
        console.log('onErrorCreateFile');
    });
}, function()
{
    console.log('onErrorLoadFs')
});

At the end, my console reads:

download complete: file:///data/user/0/com.my.app/files/files/Test.pdf

but when I try to navigate there in the My Files app, the com.my.app directory isn't there. Obviously Test.pdf isn't there either.

Here are the preferences in my config.xml:

<preference name="AndroidPersistentFileLocation" value="Internal" />
<preference name="iosPersistentFileLocation" value="Library" />
<preference name="iosExtraFilesystems" value="library,library-nosync,root" />
<preference name="AndroidExtraFilesystems" value="files,documents,root" />

What am I missing?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.355777 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO