Bun.file() 函式接受一個路徑並返回一個 BunFile 例項。BunFile 類繼承自 Blob,因此使用 .type 屬性來讀取 MIME 型別。
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
有關使用 BunFile 的更多資訊,請參閱 API > 檔案 I/O。