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

# 将 Blob 写入文件

使用 [`Bun.write()`](/runtime/file-io#writing-files-bun-write) 将 `Blob` 写入磁盘。第一个参数是*目标*，例如绝对路径或 `BunFile` 实例。第二个参数是要写入的*数据*。

```ts theme={null}
const path = "/path/to/file.txt";
await Bun.write(path, "Lorem ipsum");
```

***

`BunFile` 类继承自 `Blob`，因此你也可以直接将 `BunFile` 传递给 `Bun.write()`。

```ts theme={null}
const path = "./out.txt";
const data = Bun.file("./in.txt");

// 将 ./in.txt 的内容写入 ./out.txt
await Bun.write(path, data);
```

***

参见 [`Bun.write()`](/runtime/file-io#writing-files-bun-write)。
