HTML 5 filesystem access Type Error

老子叫甜甜 提交于 2019-12-18 17:05:19

问题


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.


回答1:


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(...)




回答2:


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...



来源:https://stackoverflow.com/questions/17116467/html-5-filesystem-access-type-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!