Skip to content

more ways of getting files #49757

Description

@jimmywarting

What is the problem this feature will solve?

it's kind of a #developer-pain that

  1. there are no sync version of fs.openAsBlob (aka: fs.openAsBlobSync)
  2. they are a Blob instead of Files 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:

What alternatives have you considered?

Only workaround today is to do:

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,
  lastModified: Number(stat.mtime)
 })

would be a heck a lot easier if i could just do:

const file = fs.openAsFileSync(filePath)

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.fsIssues and PRs related to file-system APIs and the fs module.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions