Replacing `fs.createWriteStream()` with Deno equivalent
Hi, I am trying to download files from S3 to disk and it works if I use
fs.createWriteStream()
as follows:
How would I achieve the same thing with Deno's standard library instead of node:fs
? I have tried the following:
But I get an error:
Any ideas?6 Replies
deno (and the web) and node's streaming APIs are different; so first you need to convert it using one of the node functions to get a web one: https://nodejs.org/api/stream.html#streamreadabletowebstreamreadable-options
then from there you can use
.pipeTo
on the readable with the value of the writableThanks. When I try:
I get an new error:
I get the same error with:
you want to pass the writable, not the writer (yes i know, very confusing nomenclature), so in your case
output.writable
That works! Thanks 🙏
Naming is hard 😣
If anyone is interested, this is the final working code: