WICG / proposals

A home for well-formed proposed incubations for the web platform. All proposals welcome.
https://wicg.io/
Other
227 stars 12 forks source link

Download API #111

Open Zipdox2 opened 1 year ago

Zipdox2 commented 1 year ago

Introduction

Currently there is no API for downloading files. Specifically, for downloading client-side generated files.

Downloading files is usually accomplished by creating an anchor element, setting its href attribute to the result of calling URL.createObjectURL() with a blob, and setting the download attribute to the filename. This has several limitations though:

There are two possible workarounds, but they each have their problems.

For downloading streams, you can use a trick with service workers, but service workers are not available in incognito mode, require an additional server resource, and require a secure context.

The alternate solution is to use the File System Access API's showSaveFilePicker(), however, this API is not implemented in Firefox, as Mozilla considers it harmful, and isn't available in any mobile browser. It's also only available in secure contexts.

Use Cases (Recommended)

Goals (Optional)

Non-goals (Optional)

Proposed Solution

Without being too prescriptive, articulate a specific way (procedurally, algorithmically, declaratively) that a new or current web technology solves an existing problem or challenge.

Examples (Recommended)

Alternate Approaches (Optional)

I mentioned alternate approaches in the introduction.

Privacy & Security Considerations

This API is meant to be straightforward and single-purpose, as opposed to the File System Access API. As I mentioned in the goals section, the user agent may force a prompt before every download, which could be accompanied by the usual "ignore further prompts" option as exists with window.prompt and window.alert. It should therefore be easy to shut down invasive popups. The only information I can think of that this API may reveal is the write speed and/or characteristics of the user's storage device.

Let’s Discuss (Optional)

I've previously discussed a possible download API here: https://github.com/whatwg/html/issues/4148

But I'd like to hear people's opinions on what features the API should have and what the best way to implement such an API would be.