Re: [w3c/FileAPI] Proposal: `Blob.from()` for creating virtual Blobs with custom backing storage (Issue #209)

asutherland left a comment (w3c/FileAPI#209)

A fundamental aspect of Blobs is that they are immutable when they are minted and do not require running content JS.  This allows them to be postMessaged between agents and origins without the recipient having to worry about whether the Blob is still usable (modulo storage clearing), as well as allowing APIs like IndexedDB to know they can reliably store a Blob without indefinitely hanging a transaction.

What you are proposing sounds like a combination of:
- A means of working around the lack of [a download API](https://github.com/whatwg/html/issues/4148) or expansion of [srcObject](https://github.com/whatwg/html/issues/3972) to other tags so we might be able to directly attach Response objects to an HTML tag that could initiate a download.
- A means of reproducing the ability of ServiceWorkers to create synthetic responses to network requests but without involving ServiceWorkers (but instead involving URL.createObjectURL) and requiring that streams are returned instead of Response objects.

I agree that the underlying use case of downloads without involving ServiceWorkers is poorly addressed and that existing workarounds do already frequently involve URL.createObjectURL in ways that are suboptimal from a resource-utilization perspective.  I also understand that you are explicitly talking about supporting third-party storage which is a situation where it is arguably much uglier and/or more concerning for a site to need to load potentially multiple third-party JS libs into the ServiceWorker to rely on its semantics.  (Foreign-fetch ServiceWorkers would have provided a means for this but they were explicitly ruled out.)

I think would be much less troubling in terms of impact on the web platform to fundamentally change the invariants of how Blobs work to pursue further progress on a download API and/or srcObject.

I do think further discussion of this proposal needs an explanation of how Blobs that are postMessaged are dealt with.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/FileAPI/issues/209#issuecomment-2892018569
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/FileAPI/issues/209/2892018569@github.com>

Received on Monday, 19 May 2025 19:09:29 UTC