0

I've been trying to do some CRUD operations to a local drive using chrome extensions. I understand i won't be able to access the local file system directly, a sandboxed environment will do.

LocalStorage worked for data upto 5 mb. I'll be needing more. I've found that setting "unlimitedStorage" won't grant more to the LocalStorage.

"unlimitedStorage"

Provides an unlimited quota for storing HTML5 client-side data, such as databases and local storage files. Without this permission, the extension or app is limited to 5 MB of local storage.

Note: This permission applies only to Web SQL Database and application cache (see issue 58985). Also, it doesn't currently work with wildcard subdomains such as http://*.example.com.

see chrome extension docs

I've then tried to use the FileSystemApi. But it turned out that only chrome apps can use this api.

As far as i know I'm left with 4 other options:

I've got a hunch that indexedDb will allow some form of CRUD. I'm reluctant to use WebSQL as it's deprecated and i've yet to find information about the Application cache, although i doubt that storing data for extensions is within the boundaries of its intended purpose.

Is it possible for chrome extensions to save, load and delete files on the local file system? Am i misinformed about the LocalStorage Limitations or the use of the fileSystem Api in chrome extensions? Will IndexedDB fulfill my needs?

Community
  • 1
  • 1
Lars
  • 3,022
  • 1
  • 16
  • 28
  • Depending on your use case, the [`chrome.storage`](https://developer.chrome.com/extensions/storage.html) API may be an easier / better option (available to apps and extensions). – Rob W Jun 23 '13 at 09:30
  • The HTML5 Filesystem API does work for chrome extensions. I'm using it in PageArchiver. – check_ca Jun 23 '13 at 12:32
  • @Rob-w, I've looked at the storage api, I'll add it to my question, i initially got put of by this line in the docs: "it's going to be delayed by anyone that puts into that tube enormous amounts of material." i'm not sure what google considers enormous amounts. i'll be storing about 5 gb at max. every now and then i'll be retrieving about 1 mb of data. – Lars Jun 23 '13 at 13:02
  • @check_ca : I've noticed that i was using the fileSystem Api as explained in the chrome-apps documentation. "chrome.fileSystem." instead of the "window.requestFileSystem" that is used in the html5rocks example. I'm going to give that a shot. – Lars Jun 23 '13 at 13:08
  • @user RE storage API: The storage API is most suited for small pieces of data. A quick benchmark shows that saving a string of 10M characters takes a half second. Try it yourself, run the following code in the context of an extension which has the "storage" permission: http://pastebin.com/QKFqbX2U – Rob W Jun 23 '13 at 13:09
  • @RobW : Tried it just now, That's fast enough. A get took only +/-100ms. Post it as an answer. It's kinda the same as the LocalStorage without the size limitations. – Lars Jun 23 '13 at 13:32
  • @user1203738 Although my response offers a solution to your case, it doesn't answer the question. Either post the answer yourself and explain why you've chosen my suggested API, or wait for someone who is experiencing the same situation to post an answer. – Rob W Jun 23 '13 at 13:44
  • @RobW, Sure, once i've got things working i'll try and explain my reasoning. – Lars Jun 23 '13 at 13:57

1 Answers1

0

Try with Cordova, Capacitor or similars.

In the browser, run the code in your test area, if you want to use your sandbox you need to run the application on the device (iOS, Android, Windows, Linux, etc.) and use native resources inside the sandbox, dont forget request permission.

If you work with ionic v4 you can use capacitor and mostest important is you can build for native app from web components to have your sandbox into native device!

Capacitor: https://capacitor.ionicframework.com/docs/apis/filesystem/

Cordova: https://cordova.apache.org/docs/en/latest/cordova/storage/storage.html

Zadioke
  • 1
  • 2