Skip to main content
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 > 文件输入输出