Runtime
Bundler
Package Manager
Test Runner
Guides
Reference
Blog
Install Bun
Guides File System

Write a ReadableStream to a file

To write a ReadableStream to disk, create a Response from the stream and pass it to Bun.write().

const stream: ReadableStream = ...;
const path = "./file.txt";
const response = new Response(stream);

await Bun.write(path, response);

See Bun.write().

On this page

No Headings