Repository navigation
more ways of getting files #49757
Description
Activity
- addedfeature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
on Sep 21, 2023 - addedfsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
on Sep 22, 2023 The
fs.openAsBlobshould be moved to Promises API andfs.openAsBlobSyncshould exist indeed. Drafted #49759 to address this.const name = path.basename(filePath) const stat = fs.statSync(filePath) const blob = await fs.openAsBlob(filePath) const file = new File([blob], name, { - type: blob.type, // this is always empty string + type: userProvidedMimeType, lastModified: Number(stat.mtime) })This makes me wonder, wouldn't it be inconsistent that we set
lastModifiedautomatically but don't do that withtype(using extension-mime map or libmagic)? Because the guessing should probably be done in userland.
typeproperty is read-only; so user wouldn't be able to set it after reading returnedFile, andfs.readAsFile(path, { type })would work only if they know type beforehand.The fs.openAsBlob should be moved to Promises API
Don't mind that
Drafted #49759 to address this.
👍
I would not mind if it was able to guess the correct type.
I think the mimesniff spec is being used on many web related things... such as
whatwg/fsand<input type="file">are able to figure out some common types when getting access to aFileBut i think we could focus on that later, it dose not really affect this issue directly.
i would say that is a blocker if NodeJS dose not have a built in mime sniffer.
(just created: #49843)github-actions commented
on Mar 23, 2024 on Mar 23, 2024 – with GitHub ActionsContributorMore actionsThere has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Mar 23, 2024 github-actions commented
on Apr 22, 2024 on Apr 22, 2024 – with GitHub ActionsContributorMore actionsThere has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.
For more information on how the project manages feature requests, please consult the feature request management document.
What is the problem this feature will solve?
it's kind of a #developer-pain that
fs.openAsBlob(aka: fs.openAsBlobSync)Blobinstead ofFiles and therefore lacks a file name and lastModified. So upgrading them to a File requires figuring out more stuff yourself.What is the feature you are proposing to solve the problem?
That we add:
fs.openAsFilefs.openAsFileSyncfs.openAsBlobSync(fs: fixfs.openAsBlob, addfs.openAsBlobSyncandfsPromises.openAsBlob#49759)What alternatives have you considered?
Only workaround today is to do:
would be a heck a lot easier if i could just do:
and there is no way of getting around it cuz the async openAsBlob is the only thing you can work with. which makes your own code having to be async as well.