Phonegap Build File Plugin - getDirectory issue

233 views
Skip to first unread message

Daniel Johnson

unread,
Apr 23, 2014, 8:33:34 AM4/23/14
to phon...@googlegroups.com

I'm trying to move a file that is created by the camera into a new directory but the app is failing when trying to create the new directory to move too.

I'm using Phonegap build and have no versions set in my config.xml file.

I've added these two preferences to the config.xml 

<preference name="iosExtraFilesystems" value="library,library-nosync,documents,documents-nosync,cache,bundle,root" />
<preference name="iosPersistentFileLocation" value="Library" />

After taking the photo the movePic function is called as the success of the getPhoto. The problem appears to be in the call to fs.root.getDirectory, where i'm getting an error code 3.

Any help would be massively appreciated!

function moveFileEntry(fs, fileEntry, dirName) {

    fs.root.getDirectory(dirName, { create: true },
        function (dirEntry) {
            fileEntry.moveTo(dirEntry, newFilename(), successFileEx);
        },
        function (error) {
            //ERROR HERE >  fs.root.getDirectory ' + error.code = 3
        }
    );
}

function resolveOnSuccessMove(entry) {

    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) {
        moveFileEntry(fs, entry, 'MyApp/');
    },
    function (error) {
        fileOpsDebug('error - window.requestFileSystem');
    });
}

function movePic(file) {
    window.resolveLocalFileSystemURI(file, resolveOnSuccessMove,
        function (error) {
        });
}

Daniel Johnson

unread,
Apr 23, 2014, 10:51:04 AM4/23/14
to phon...@googlegroups.com
Just tried this again and I can actually replicate with this very simple example using an app built for the iPad with Phonegap build.

Note: fileOpsDebug is a function that I have for debugging. It exports the message to a html control..

After running this code I get "got file system", "creation failed"

        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
            function (fileSys) {
                fileOpsDebug('got file system ');
                fileSys.root.getDirectory('Test1',
                    { create: true, exclusive: false },
                    function (directory) {
                        fileOpsDebug('created dir ');
                    },
                    function (error) {
                        fileOpsDebug('creation failed ');                                    
                    });
            },
            function (error) {
                fileOpsDebug('file system failed ');
            });

Daniel Johnson

unread,
Apr 23, 2014, 12:01:27 PM4/23/14
to phon...@googlegroups.com
here's the config.xml file for reference:

<?xml version="1.0" encoding="UTF-8" ?>
    <widget xmlns   = "http://www.w3.org/ns/widgets"
        xmlns:gap   = "http://phonegap.com/ns/1.0"
        id          = "com.myapp.blahblahblah"
        versionCode = "10" 
        version     = "1.0.385" >

    <!-- versionCode is optional and Android only -->

    <name>myapp</name>

    <description>
        some description
    </description>

    <author email="m...@email.com" href="http://mywebsite">
    </author>
<preference name="orientation" value="both" />
<preference name="target-device" value="universal" />
<preference name="exit-on-suspend" value="false" />
<preference name="DisallowOverscroll" value="true"/>
<preference name="iosExtraFilesystems" value="library,library-nosync,documents,documents-nosync,cache,bundle,root" />
<preference name="iosPersistentFileLocation" value="Library" />

<gap:platform name="ios" />
<gap:platform name="android" />
<gap:platform name="winphone" />
<icon src="img/icon.png" gap:role="default" />
<icon src="icons/ios/icon.png" gap:platform="ios" width="57" height="57" />
<icon src="icons/ios/icon-72.png" gap:platform="ios" width="72" height="72" />
<icon src="icons/ios/icon_at_2x.png" gap:platform="ios" width="114" height="114" />

<!-- retina iPad support: PhoneGap 2.5.0+ only -->
<icon src="icons/ios/icon-72_at_2x.png" gap:platform="ios" width="144" height="144" />
<icon src="icons/android/ldpi.png" gap:platform="android" gap:density="ldpi" />
<icon src="icons/android/mdpi.png" gap:platform="android" gap:density="mdpi" />
<icon src="icons/android/hdpi.png" gap:platform="android" gap:density="hdpi" />
<icon src="icons/android/xhdpi.png" gap:platform="android" gap:density="xhdpi" />
<icon src="icons/winphone/icon.png" gap:platform="winphone" />
<icon src="icons/winphone/tileicon.png" gap:platform="winphone" gap:role="background" />

<gap:plugin name="org.apache.cordova.camera" version="0.2.4" />
<gap:plugin name="org.apache.cordova.device" version="0.2.8" />
<gap:plugin name="org.apache.cordova.dialogs" version="0.2.6" />
<gap:plugin name="org.apache.cordova.file" version="1.0.1" />
<gap:plugin name="org.apache.cordova.file-transfer" version="0.4.2" />
<gap:plugin name="org.apache.cordova.network-information" version="0.2.7" />
    <access origin="*"  />
</widget>

Reply all
Reply to author
Forward
Message has been deleted
0 new messages