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

Getting Files backed up by the filesystem #37340

Closed
jimmywarting opened this issue Feb 13, 2021 · 4 comments
Closed

Getting Files backed up by the filesystem #37340

jimmywarting opened this issue Feb 13, 2021 · 4 comments
Labels
feature request Issues that request new features to be added to Node.js. fs Issues and PRs related to the fs subsystem / file system. stale

Comments

@jimmywarting
Copy link

jimmywarting commented Feb 13, 2021

Is your feature request related to a problem? Please describe.
Blobs are merely pretty useless if they can only be constructed and held in memory.
A way to get blobs from the filesystem is necessary if we should see any use for them
I propose we add support for getting blob's from the filesystem before we start adding support for them in other places like the crypto, streams, fs and other place

After all writing a blob back to the filesystem can be as easy as creating a stream and piping it back to the filesystem or to a http request

Describe the solution you'd like

fs.promises.getBlob('./4gb.dat') // just so we can start using the blob
fs.promises.getFile('./4gb.dat') // think this requires a File class

// It should not be a issue to get a blob sync, the data should not be held in memory anyway
// the only thing that should be read is modified time and the file size (and filename for `.getFile()`)
// it should only be a pointer to where it should read the data from ( like a handle )
fs.getBlobSync('./4gb.dat')

if the modified time is changed when you try to read the blob then it should throw a NotReadableError DOMException saying that it's out of sync. Likewise if size is changed.

Describe alternatives you've considered
fetch-blob has a "BlobDataItem" that is backed up by the filesystem...


assume this depends somewhat on #37338 and #39015 being resolved first

@jimmywarting jimmywarting changed the title Getting a Blobs backed up by the filesystem Getting Blobs backed up by the filesystem Feb 13, 2021
@Ayase-252 Ayase-252 added feature request Issues that request new features to be added to Node.js. fs Issues and PRs related to the fs subsystem / file system. labels Apr 13, 2021
@jimmywarting jimmywarting changed the title Getting Blobs backed up by the filesystem Getting Files backed up by the filesystem Jul 7, 2021
@jimmywarting
Copy link
Author

jimmywarting commented Apr 28, 2022

browser has something new on drag and drop'ed files & folders DataTransferItem.prototype.getAsFileSystemHandle to get things as a whatwg/fs handle

i think we could have something like getAsFileSystemHandle added onto the fs.Dirent

Some proposals

import { readdir, getAsFileSystemHandle } from 'fs/promises'
const handle = await getAsFileSystemHandle(path)

const [dirent] = readdir(path, { withFileTypes: true })
const handle = await dirent.getAsFileSystemHandle()

const file = await handle.getFile()
const text = await file.text()

@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2023

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

@github-actions github-actions bot added the stale label Mar 6, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 6, 2023

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

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 6, 2023
@jimmywarting
Copy link
Author

just for the sake of it:

fixed / closed by #45258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. fs Issues and PRs related to the fs subsystem / file system. stale
Projects
None yet
Development

No branches or pull requests

2 participants