0

I am using this script:

window.navigator.webkitTemporaryStorage.queryUsageAndQuota(function(used, remaining) {
     console.log('Used space', used);
     console.log('Remaining space', remaining);
   }, function(err) {
     console.warn(err);
   });

but I get:

undefined
Used space 0
Remaining space 5027736601
xRobot
  • 25,579
  • 69
  • 184
  • 304

1 Answers1

0

I guess the code you are using of for HTML 5 file system api. check this. this window.webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.TEMPORARY, console.log.bind(console)) also returns same as your code. you can calculate used localstorage you can use something like this:

var _lsTotal=0,_xLen,_x;for(_x in localStorage){_xLen= ((localStorage[_x].length + _x.length)* 2);_lsTotal+=_xLen; console.log(_x.substr(0,50)+" = "+ (_xLen/1024).toFixed(2)+" KB")};console.log("Total = " + (_lsTotal / 1024).toFixed(2) + " KB");

Took it from here.

Chrome allows 5MB of data or 5101 k character as per this test so you can calculate the remaining storage.

Community
  • 1
  • 1
Sajan
  • 1,893
  • 2
  • 19
  • 39