diff options
Diffstat (limited to 'docs/guides/read-file/mime.md')
-rw-r--r-- | docs/guides/read-file/mime.md | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/guides/read-file/mime.md b/docs/guides/read-file/mime.md new file mode 100644 index 000000000..44a8e6860 --- /dev/null +++ b/docs/guides/read-file/mime.md @@ -0,0 +1,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`. |