> ## 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.

# 获取文件的 MIME 类型

`Bun.file()` 函数接受一个路径并返回 `BunFile` 实例。`BunFile` 类继承自 `Blob`，因此使用 `.type` 属性读取 MIME 类型。

```ts theme={null}
const file = Bun.file("./package.json");
file.type; // application/json;charset=utf-8

const file = Bun.file("./index.html");
file.type; // text/html;charset=utf-8

const file = Bun.file("./image.png");
file.type; // image/png
```

***

参见 [文件 I/O](/runtime/file-io) 了解如何使用 `BunFile`。
