Robbie
Robbie
DDeno
Created by Robbie on 11/28/2024 in #help
Replacing `fs.createWriteStream()` with Deno equivalent
If anyone is interested, this is the final working code:
import { S3 } from "npm:@aws-sdk/client-s3@3.701.0";

const s3 = new S3();
const response = await s3.getObject({ Bucket: "mybucket", Key: "mykey" });
const output = await Deno.open("out.dat", { write: true, create: true });
const result = await response.Body.transformToWebStream().pipeTo(output.writable);
import { S3 } from "npm:@aws-sdk/client-s3@3.701.0";

const s3 = new S3();
const response = await s3.getObject({ Bucket: "mybucket", Key: "mykey" });
const output = await Deno.open("out.dat", { write: true, create: true });
const result = await response.Body.transformToWebStream().pipeTo(output.writable);
9 replies
DDeno
Created by Robbie on 11/28/2024 in #help
Replacing `fs.createWriteStream()` with Deno equivalent
That works! Thanks 🙏
9 replies
DDeno
Created by Robbie on 11/28/2024 in #help
Replacing `fs.createWriteStream()` with Deno equivalent
I get the same error with:
const result = await response.Body.transformToWebStream().pipeTo(outputWriter);
const result = await response.Body.transformToWebStream().pipeTo(outputWriter);
9 replies
DDeno
Created by Robbie on 11/28/2024 in #help
Replacing `fs.createWriteStream()` with Deno equivalent
Thanks. When I try:
const result = await Readable.toWeb(response.Body).pipeTo(outputWriter);
const result = await Readable.toWeb(response.Body).pipeTo(outputWriter);
I get an new error:
Stack trace:
TypeError: Failed to execute 'pipeTo' on 'ReadableStream': Argument 1 is not of type WritableStream
at makeException (ext:deno_webidl/00_webidl.js:93:10)
at Array.WritableStream (ext:deno_webidl/00_webidl.js:1120:13)
at ReadableStream.pipeTo (ext:deno_web/06_streams.js:5303:39)
at <anonymous>:13:52
at eventLoopTick (ext:core/01_core.js:175:7)
Stack trace:
TypeError: Failed to execute 'pipeTo' on 'ReadableStream': Argument 1 is not of type WritableStream
at makeException (ext:deno_webidl/00_webidl.js:93:10)
at Array.WritableStream (ext:deno_webidl/00_webidl.js:1120:13)
at ReadableStream.pipeTo (ext:deno_web/06_streams.js:5303:39)
at <anonymous>:13:52
at eventLoopTick (ext:core/01_core.js:175:7)
9 replies