Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jkleinsc/polypolyfile

What happens you try to use the FileSystem API polyfill on top of the IndexedDB polyfill?
https://github.com/jkleinsc/polypolyfile

Last synced: 11 days ago
JSON representation

What happens you try to use the FileSystem API polyfill on top of the IndexedDB polyfill?

Awesome Lists containing this project

README

        

PolypolyFile
============

What happens you try to use the FileSystem API polyfill on top of the IndexedDB polyfill?
![alt tag](http://jkleinsc.github.io/PolypolyFile/polypoly.jpg)

You get the following demo: http://jkleinsc.github.io/PolypolyFile

1. There is a polyfill for the FileSystem API (//github.com/ebidel/idb.filesystem.js/), that relies on IndexedDB.
2. There is a polyfill for the IndexedDB API that relies on WebSQL (https://github.com/axemclion/IndexedDBShim).
3. Can you use polyfill #1 on top of polyfill #2?
4. If you can, the FileSystem API can be used in most browsers, including Safari and mobile Safari(iOS).

When I started this project, it turned out that the IndexedDB polyfill simply used
JSON.stringify/JSON.decode to mimic the Structured Cloning Algorithm. This meant
that the FileSystem polyfill didn't work because it was using Blobs to save the files
in the IndexedDB. Blobs get converted to null when you attempt to convert them using JSON.stringify.

After examining the IndexedDB polyfill, I decided to properly implement the Structured
Cloning Algorithm for that polyfill. That implementation has been accepted as a pull
request for the IndexedDB polyfill: GitHub pull request

What you see in this project is an example of the FileSystem polyfill and the
IndexedDB polyfill working together to allow upload of photos to a local filesystem
from a (mobile) Safari browser. This example should work in most browsers.