Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jsoref opened this issue Oct 31, 2024 · 2 comments
Closed
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest

Comments

@jsoref
Copy link

jsoref commented Oct 31, 2024

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.

Anything else?

No response

@jsoref jsoref added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Oct 31, 2024
@domenic
Copy link
Member

domenic commented Nov 1, 2024

This standard doesn't have any method called createObjectURL. I think you want https://w3c.github.io/FileAPI/.

@domenic domenic closed this as completed Nov 1, 2024
@jsoref
Copy link
Author

jsoref commented Nov 1, 2024

Thanks, refiled as w3c/FileAPI#203

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

No branches or pull requests

2 participants