H
Hono6mo ago
Riven

ctx.req: readable stream

noticed there's documentation for sending a steam, but having difficulty reading one from the Context
1 Reply
Riven
RivenOP6mo ago
would like to access a ReadStream or be able to pipe a writable to the request i think i have a solution:
const writeStream = createWriteStream(tarballPath);
const writableStream = new WritableStream({
write(chunk) {
writeStream.write(chunk);
},
close() {
writeStream.end();
},
abort(err) {
writeStream.destroy(err);
},
});

await ctx.req.raw.body!.pipeTo(writableStream);
const writeStream = createWriteStream(tarballPath);
const writableStream = new WritableStream({
write(chunk) {
writeStream.write(chunk);
},
close() {
writeStream.end();
},
abort(err) {
writeStream.destroy(err);
},
});

await ctx.req.raw.body!.pipeTo(writableStream);
would be nice to not require accessing the raw body though
Want results from more Discord servers?
Add your server