window.requestFileSystem not working

1,267 views
Skip to first unread message

Ash test

unread,
Feb 17, 2012, 1:36:59 PM2/17/12
to phonegap
I am not able to access file system using file api on iOS. It throws
an exception "'undefined' is not a function (evaluating
'window.requestFileSystem')"

Here is my code:

function initfilesystem()
{
try{
window.requestFileSystem(
LocalFileSystem.PERSISTENT,
5*1024*1024,
function(fileSystem){
console.log(fileSystem.name);
alert(fileSystem.name);
console.log(fileSystem.root.name);
alert(fileSystem.root.name);
file.root.getfile(
sImgURL,
{create: false},
function(fileEntry){
fileEntry = fileEntry;
},
fail);
},
fail);
}catch(e){
//Any other error
alert('Could not open filesystem, errorcode: ' + e);
}
}

Could some one help me with this. I am developing on iOS.

Shazron

unread,
Feb 17, 2012, 5:35:52 PM2/17/12
to phon...@googlegroups.com
That code cannot run stand-alone, so many problems with it (magic
vars).But I verified that window.requestFileSystem works in 1.4.1

> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com

Kerri Shotts

unread,
Feb 18, 2012, 2:11:31 PM2/18/12
to phon...@googlegroups.com
Better to open the filesystem (and read/write) by doing something like here: http://pastebin.com/u5XXQDub

Essentially you have lots of callbacks until you get down to the file you want to read/write to. Clumsy, but it works better that way. Also be certain that you give some time for the filesystem to initialize upon app start -- best to wait until you hear a deviceready event and then even better to wait /just/ a little bit longer (say, 125ms).
Reply all
Reply to author
Forward
0 new messages