Reputation: 483
Trying to create a file using the sandboxed FileSystem API:
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(
window.PERSISTENT,
1024 * 1024,
function( fs ) {
fs.root.getFile( 'test.txt', {create: true}, function( fe )
{
alert( "OK" );
}, function( e )
{
alert( e.code );
}
);
}, null
);
I always get the error code 10 (QUOTA_EXCEEDED_ERR
) on this code.
Chrome: 17.0.963.79 m
, started with --allow-file-access-from-files
flag.
What am I doing wrong?
Upvotes: 1
Views: 1506
Reputation: 3531
Very useful answer by pimvdb. As of now (October 2013) Chrome reports webkitStorageInfo
as deprecated. Instead, prefer the following:
navigator.webkitPersistentStorage.requestQuota(
2048, //bytes of storage requested
function(availableBytes) {
console.log(availableBytes);
}
);
To request temporary storage, use navigator.webkitTemporaryStorage.requestQuota
Upvotes: 0
Reputation: 154838
For persistent storage, you have to explicitly ask for permission of the user:
webkitStorageInfo.requestQuota(
webkitStorageInfo.PERSISTENT,
1000, // amount of bytes you need
function(availableBytes) {
alert("Quota is available. Quota size: " + availableBytes);
// you can use the filesystem now
}
);
You can also choose for temporary storage.
Upvotes: 2