0

I'm using File System Access API (https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API) to read and write a file into disk. This is my code;

const writable = await cacheFileHandle.createWritable({ keepExistingData: false });
await writable.write(JSON.stringify(cache));
await writable.close();

This code fails with Uncaught (in promise) DOMException: The operation failed because it would cause the application to exceed its storage quota. error. This began when the file reached 10MB. Is there any way to solve this?

Note:
I already tried the HTML File API solutions.

  • I tried window.webkitStorageInfo.requestQuota(window.PERSISTENT, 10240*10240,()=>{...},()=>{...}). That didn't work.
  • Another solution was to put unlimitedStorage to the manifest.json, but this is a react app, so that didn't help either.
Akshay K Nair
  • 1,107
  • 16
  • 29
  • 1
    https://stackoverflow.com/questions/22455634/quota-exceeded-trying-to-create-file-with-html-file-api – Elvis Pimentel May 21 '22 at 06:15
  • @ElvisPimentel, already tried that (pointed it out in the "note:"). Sadly that is for chrome extensions and packaged apps. This is completely different, as this doesn't have a manifest or anything. – Akshay K Nair May 21 '22 at 07:55
  • 1
    I think your problem is elsewhere, since [`WritableStreamDefaultWriter.write()`](https://streams.spec.whatwg.org/#default-writer-write) doesn't fail with a `DOMException`, but with a `TypeError`. You probably hit a storage quota issue somewhere else. – DenverCoder9 Jun 20 '22 at 13:36

0 Answers0