Jump to content

HTML5: Filesystem API Chrome 30


VapoRizer
 Share

Recommended Posts

I need to save some files to a persistent local file system. A week ago I started a thread on stackexchange on this topic. Hopefully I can find some experts here:

 

I have following code in my app.js:

function onInitFs(fs) {    aGlobalFsRoot = fs.root;    console.log('04Position');    alert("Welcome to Filesystem! It's showtime :)"+fs); // Just to check if everything is OK }function openFS() {navigator.webkitPersistentStorage.requestQuota (1*1024*1024, function(grantedBytes) {  console.log ('test1');  reqFS(grantedBytes);}, errorHandler);}function reqFS(grantedBytes) {  window.webkitRequestFileSystem(window.PERSISTENT, grantedBytes, function(fs) {    console.log ('test2');    alert("Welcome to Filesystem! It's showtime :)"+fs); // Just to check if everything is OK   }, errorHandler);}function errorHandler(e) {  var msg = '';  switch (e.code) {    case FileError.QUOTA_EXCEEDED_ERR:      msg = 'QUOTA_EXCEEDED_ERR'+e;      break;    case FileError.NOT_FOUND_ERR:      msg = 'NOT_FOUND_ERR'+e;      break;    case FileError.SECURITY_ERR:      msg = 'SECURITY_ERR z.B. Speicherplatz wurde abgelehnt.'+e;      break;    case FileError.INVALID_MODIFICATION_ERR:      msg = 'INVALID_MODIFICATION_ERR'+e;      break;    case FileError.INVALID_STATE_ERR:      msg = 'INVALID_STATE_ERR'+e;      break;    default:      msg = 'Unknown Error'+e;      break;  };  console.log('Error: ' + msg);}
openFS is called on pageload. The code is based on this topic (where it also doesn't seem to work for newer versions of chrome). I can't get it to work. All the time, the errorHandler is called. It makes no difference if the filesystem already exists or not. The quota seems to work.

I get two different console logs:

  1. When accsess is granted by user:

    Error: Unknown Error[object DOMError] app.js:81

  2. When access is denied by user:

    test1 app.js:45 Error: SECURITY_ERR z.B. Speicherplatz wurde abgelehnt.[object FileError] app.js:81

Anyone got this working?

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...