w3c / w3c/FileAPI

Allow `createObjectURL` to retain filename from `File` (and similar) objects

Offen
#203 7 Kommentare 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
HTML
Sterne
118
Forks
52
Ø Merge
9 T. 16 Std.
Gemergte PRs (30 T.)
1

Beschreibung

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 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 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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Lesen Sie zunächst die File API-Spezifikation rund um den Einstiegspunkt createObjectURL sowie die Definitionen von File, Blob und object URLs. Ermitteln Sie, wie ein vorgeschlagener Dateiname mit dem Speicherverhalten interagieren sollte, und aktualisieren Sie anschließend die Spezifikation, um diese Präferenz zu definieren, und fügen Sie Konformitätsabdeckung hinzu oder passen Sie sie an, falls die Spezifikation eine relevante Teststelle identifiziert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
html
Bereich
api, web-dev
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.