Skip to main content

Get the MIME type of a file

还没翻译译自英文(bun.com)本页 3 段都还没译

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.

const file = Bun.file("./package.json");
file.type; // application/json;charset=utf-8

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

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

See File I/O for more on working with BunFile.

번역 © 2026 fanyi.dev · 원문 © 2026 the Bun project (LICENSE.md names no copyright holder) (MIT)