- From: Josh Soref <notifications@github.com>
- Date: Thu, 31 Oct 2024 17:35:55 -0700
- To: w3c/FileAPI <FileAPI@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/FileAPI/issues/203@github.com>
### What problem are you trying to solve? We have a datastore that requires authentication to retrieve files (e.g. PDF, CSV, ZIP, PNG, or some Office suite file format) -- it has a file name, a content type, and data. We'd like to allow users to click a link (or button/...) and have the "file" corresponding to that data (which we currently retrieve in a Blob) open in their browser (or download depending on how the browser is feeling) and if at some point the browser decides to save the file (e.g. because the user asks to save a file, or because it doesn't have an internal handler) then we'd like it to favor our proposed filename instead of a blob id. ### What solutions exist today? 1. We can construct a `Blob` or a `File` w/ a `Blob` and call `createObjectURL` with it. 2. We can create an anchor `a` with [`a#download`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download) with the href set the the url from `createObjectURL` such that users can click the anchor to get our suggested filename. 3. We can add an iframe containing our blob url Fwiw, Microsoft had an [`msSaveBlob`](https://learn.microsoft.com/en-us/previous-versions/hh772331\(v=vs.85\)) which included a `defaultName` field... ### How would you solve it? Change the specification for `createObjectURL` so that for objects that have a name (e.g. `File`), browsers should _prefer_ that name over the blob when saving. -- Reply to this email directly or view it on GitHub: https://github.com/w3c/FileAPI/issues/203 You are receiving this because you are subscribed to this thread. Message ID: <w3c/FileAPI/issues/203@github.com>
Received on Friday, 1 November 2024 00:36:04 UTC