fs: add Blob support to writeFile and appendFile#64611
Open
aelhor wants to merge 1 commit into
Open
Conversation
jasnell
approved these changes
Jul 20, 2026
Allow writeFile() and appendFile() (and their FileHandle variants) to accept a Blob, converting it to a web ReadableStream via blob.stream(). Signed-off-by: Ahmed Elhor <aelhor90@gmail.com>
aelhor
force-pushed
the
fs-writefile-blob
branch
from
July 20, 2026 22:48
d6945db to
e8258fd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
the issue actually asks. Use this corrected body instead:
This PR addresses part of #61684 by adding
Blobsupport to thewriteFile/appendFilefamily:fsPromises.writeFile(data)fsPromises.appendFile(data)(also broadens the documenteddataunion from{string|Buffer}to the full set)filehandle.writeFile(data)filehandle.appendFile(data)Implementation
A
Blobis converted to a webReadableStreamviablob.stream()and consumed through the existing async-iterable path inwriteFile. This is a small, ~6-line change that reuses existing infrastructure. Native zero-copy via a C++ blob handle is explicitly deferred as future work.Tests
New
test/parallel/test-fs-writefile-blob.jscovers all 4 entry points, plus empty blob, binary blob, large blob (multi-chunk), explicitencodingoption, andAbortSignalcancellation.Scope: this covers the
writeFile/appendFileportion of the issue's first ask. Remaining items from #61684 (the positionalfilehandle.write(blob), and the webfs.createWritableStreamcounterpart) will be tracked as separate follow-up PRs to keep this focused.Refs: #61684