> ## Documentation Index
> Fetch the complete documentation index at: https://bun.zhcndoc.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 将 ReadableStream 写入文件

要将 `ReadableStream` 写入磁盘，首先从流创建一个 `Response` 实例。然后可以使用 [`Bun.write()`](/runtime/file-io#writing-files-bun-write) 将该 `Response` 写入磁盘。

```ts theme={"theme":{"light":"github-light","dark":"dracula"}}
const stream: ReadableStream = ...;
const path = "./file.txt";
const response = new Response(stream);

await Bun.write(path, response);
```

***

完整的 `Bun.write()` 文档请参见 [文档 > API > 文件 I/O](/runtime/file-io#writing-files-bun-write)。
