GoogleChromeLabs / browser-fs-access

File System Access API with legacy fallback in the browser
https://googlechromelabs.github.io/browser-fs-access/demo/
Apache License 2.0
1.37k stars 82 forks source link

Support Promise<Blob> as input #108

Closed tmcw closed 2 years ago

tmcw commented 2 years ago

Okay, this is another approach to https://github.com/GoogleChromeLabs/browser-fs-access/pull/104 because it is turning out to be extremely difficult to support Safari and Firefox and implement streams.

Instead of doing a roundtrip from Blob to Response (with a handcrafted ReadableStream), this just lets you pass a Promise<Blob> to browser-fs-access. Much simpler, and much harder to mess up. I've tried many variations of creating a ReadableStream object that works across browsers as the data of a Response. There are almost no examples of properly doing so, it's very easy to get it wrong, and it's unnecessary indirection for both browser-fs-access and module consumers if the data is originally in some Blob or string format.