Skip to content

fs: add Blob support to writeFile and appendFile#64611

Open
aelhor wants to merge 1 commit into
nodejs:mainfrom
aelhor:fs-writefile-blob
Open

fs: add Blob support to writeFile and appendFile#64611
aelhor wants to merge 1 commit into
nodejs:mainfrom
aelhor:fs-writefile-blob

Conversation

@aelhor

@aelhor aelhor commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

the issue actually asks. Use this corrected body instead:
This PR addresses part of #61684 by adding Blob support to the writeFile / appendFile family:

  • fsPromises.writeFile(data)
  • fsPromises.appendFile(data) (also broadens the documented data union from {string|Buffer} to the full set)
  • filehandle.writeFile(data)
  • filehandle.appendFile(data)

Implementation

A Blob is converted to a web ReadableStream via blob.stream() and consumed through the existing async-iterable path in writeFile. 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.js covers all 4 entry points, plus empty blob, binary blob, large blob (multi-chunk), explicit encoding option, and AbortSignal cancellation.

Scope: this covers the writeFile/appendFile portion of the issue's first ask. Remaining items from #61684 (the positional filehandle.write(blob), and the web fs.createWritableStream counterpart) will be tracked as separate follow-up PRs to keep this focused.

Refs: #61684

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Jul 19, 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
aelhor force-pushed the fs-writefile-blob branch from d6945db to e8258fd Compare July 20, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants