Conversation
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>
d6945db to
e8258fd
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64611 +/- ##
==========================================
- Coverage 90.14% 90.13% -0.02%
==========================================
Files 741 741
Lines 242076 242081 +5
Branches 45558 45553 -5
==========================================
- Hits 218216 218190 -26
- Misses 15385 15401 +16
- Partials 8475 8490 +15
🚀 New features to boost your workflow:
|
|
Could someone from the fs team take another look at this? The previous approval became stale after the latest changes, and the PR now just needs one reapproval to unblock the merge. Thanks! |
|
@jasnell Friendly ping when you have a moment. I corrected only the commit message; the code itself is unchanged, but this made the previous approval stale. Could you please review and re-approve the latest commit? Thank you! |
This comment was marked as resolved.
This comment was marked as resolved.
You are right, I updated the pr body |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Jenkins CI is showing successful, so I've marked the PR as
author ready
|
Thanks @MikeMcC399 for running the CI and updating the status! |
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