Reputation: 672
After look up of Storage I want to try to reset the temporary storage for testing purposes.
window.webkitStorageInfo.requestQuota(webkitStorageInfo.TEMPORARY, 5*1024*1024,
function( bytes ) {
console.log( "Quota is available: " + bytes );
},
function( e ) {
console.log( "Error allocating quota: " + e );
});
window.webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.TEMPORARY,
//the type can be either TEMPORARY or PERSISTENT
function(used, remaining) {
console.log("Used quota: " + used + ", current quota: " + remaining);
}, function(e) {
console.log('Error', e);
});
The requestQuota() set the temporary storage size and the queryUsageAndQuota() tell me what is the current quota. However when I look at the console log in the chrome browser although the new quota is set, it is not reflected by the queryUsageAndQuota()
. I got something look like:
Quota is available: 5242880
Used quota: 0, current quota: 214748364
even though I expected what is avaliable and the current quota to be the same. Why is that?
Upvotes: 1
Views: 402
Reputation: 18534
Compare these two Outputs
window.webkitStorageInfo.requestQuota(webkitStorageInfo.TEMPORARY,
5188955171*1024*1024,
function( bytes ) {
console.log( "Quota is available: " + bytes );
},
function( e ) {
console.log( "Error allocating quota: " + e );
});
window.webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.TEMPORARY,
//the type can be either TEMPORARY or PERSISTENT
function(used, remaining) {
console.log("Used quota: " + used + ", current quota: " + remaining);
}, function(e) {
console.log('Error', e);
});
Quota is available: 5188982205
Used quota: 492, current quota: 5188982205
window.webkitStorageInfo.requestQuota(webkitStorageInfo.TEMPORARY, 5*1024*1024,
function( bytes ) {
console.log( "Quota is available: " + bytes );
},
function( e ) {
console.log( "Error allocating quota: " + e );
});
window.webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.TEMPORARY,
//the type can be either TEMPORARY or PERSISTENT
function(used, remaining) {
console.log("Used quota: " + used + ", current quota: " + remaining);
}, function(e) {
console.log('Error', e);
});
Quota is available: 5242880
Used quota: 0, current quota: 214748364
In your case you have requested for a minor quota 5242880
which is already available and less than available amount, so it returns a successCallback
with quota requested for! Reset the quota by requesting large number!
window.webkitStorageInfo.requestQuota is used for asking more storage than available, how ever Chrome automatically gives your app temporary storage, so you do not need to request allocation ( Maximum 20% of the shared pool)
Upvotes: 2