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 
1
  • Everything working as expected. What's your problem with this code? Commented Oct 15, 2016 at 13:16

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.