Search code examples
htmlfileapi

Open binary file from HTML5 offline web application


I'm able to use HTML5 standard File API and IndexedDB to store large binary files in the browser.

However, when offline, I need to be able to open these files. Using data URLs works great for small files, but none of the browsers support 10Mb file opening through data URL. Is there any other solution, except for non-standard window.webkitRequestFileSystem?


Solution

  • I've actually found an answer here: https://developer.mozilla.org/en/docs/Web/API/Blob.

    It is possible to save result of FileReader.readAsArrayBuffer in IndexedDB. When offline, it is possible to create a blob from this typed array and then create data URL to be passed to window.open function. Works with large files!