HTML 5 filesystem access Type Error
Asked Answered
I

2

5

I'm working on a webapp and I'm trying to access directories using the filesystem API. I need to request a quota from the user before accessing the directories according to specification. I should do something like this:

...
navigator.webkitPersistentStorage.requestQuota(PERSISTENT, 1024*1024, 
function(gB){
   window.requestFileSystem(PERSISTENT, gB, onInitFs, errorHandler);
}, function(e){
   console.log('Error', e);
})
...

Everytime I do this I get a **TypeError: Type error** message. Please what am I doing wrong? Thanks in advance.
NB: onInitFs and errorHandler have been defined I just didn't include the code here.

Injector answered 14/6, 2013 at 20:6 Comment(2)
for starters, i don't see onInitFs or errorHandler defined...Referendum
they've being defined... that's not the problem.. thanks anyway.Injector
S
5

I was having the same issues and someone posted the solution, found at filesystem-api-not-working-in-chrome-v27-v29

navigator.webkitPersistentStorage.requestQuota(1024*1024, 
  function(gB){
  window.requestFileSystem(PERSISTENT, gB, onInitFs, errorHandler);
}, function(e){
  console.log('Error', e);
})

You have to remove the PERSISTENT from navigator.webkitPersistentStorage.requestQuota(...)

Soy answered 23/7, 2013 at 12:53 Comment(0)
R
0

this version, from https://developers.google.com/chrome/whitepapers/storage seems to at least get further along:

window.webkitStorageInfo.requestQuota(PERSISTENT, 1024*1024, function(grantedBytes) {
  window.webkitRequestFileSystem(PERSISTENT, grantedBytes, onInitFs, errorHandler); 
}, function(e) {
  console.log('Error', e); 
});

it's window instead of navigator...

Referendum answered 14/6, 2013 at 21:22 Comment(2)
Yes thank you, this works. By the way the reason i used 'navigator' instead of 'window' is because I keep getting these warning messages: 'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.Injector
You shouldn't use windew.webkitStorageInfo, it's currently deprecatedBerthoud

© 2022 - 2024 — McMap. All rights reserved.