aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/read-file/mime.md
blob: 44a8e686072bb26ce93111c8f4c6cf3965e1e468 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
---
name: Get the MIME type of a file
---

The `Bun.file()` function accepts a path and returns a `BunFile` instance. The `BunFile` class extends `Blob`, so use the `.type` property to read the MIME type.

```ts
const file = Bun.file("./package.json");
file.type; // application/json

const file = Bun.file("./index.html");
file.type; // text/html

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

---

Refer to [API > File I/O](/docs/api/file-io) for more information on working with `BunFile`.