I want to save an unlimited number of files to the users hard drive, without making the user click through a dialog box.
The only documentation I have seen on using unlimited storage is here: https://developers.google.com/chrome/whitepapers/storage, which says that it is only available to Chrome apps.
All of the examples I have seen of the Chrome fileSystem
API suggest that in order to create a new file and write to it, the user needs to obtain an entry object from the chrome.fileSystem.chooseEntry
function, which means the user needs to go through a dialog box.
The regular fileSystem
API looks like it can save a file to the user's extension sandbox without making the user go through a dialog box, but I'm wondering, does it have the "unlimitedStorage"
permission that is only given to apps? It wouldn't shock me if only the Chrome API has that permission.
If I use the regular fileSystem
API, I need to request the filesystem using window.webkitRequestFileSystem
(I'm a little surprised window.requestFileSystem
isn't working for me in Chrome), but the method takes type
("persistent"
or "temporary"
), and size
(the bytes the app will require for storage) arguments.
You obviously don't do that in the Chrome API. However, the normal fileSystem
API lets you request more storage when you need it using the Quota Management API, which is also documented on the page I linked above
And on https://developers.google.com/chrome/apps/docs/developers_guide#manifest, it says:
The
"permissions"
field lets you specify HTML5 permissions that the app requires. By specifying"unlimitedStorage"
and"notifications"
, this app is able to use those HTML5 features without having to repeatedly ask the user for permission. During app installation, the user is told which permissions the app needs; installing the app implicitly grants those permissions for all pages whose URLs match those in the"apps"
field of the manifest.
So I'm hoping that the "unlimitedStorage"
permission simply means that I can just call window.webkitRequestFileSystem(window.PERSISTENT, anySize, successCallback)
, and instead of asking the user to raise the quota when it needs to, Chrome automatically does it.
Question 1: Does anyone know if that's the way it works?
However, if only the the chrome API has that "unlimitedStorage"
permission, I could try creating a file entry with the regular API, and passing that entry into the Chrome API functions, therefore skipping the need for a dialog box, and gaining access to the "unlimitedStorage"
permission.
Question 2: Is it possible for me to create the entry in one API and pass it to the other? I'm afraid the different API's might have different sandboxes.
The documentation on the fileSystem
API's isn't great, so I figured I'd ask to see if anybody knew from previous experience. The fewer rabbit holes the better.