Skip to content

La fonction Bun.file() accepte un chemin et retourne une instance BunFile. La classe BunFile étend Blob, utilisez donc la propriété .type pour lire le type MIME.

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

Consultez API > E/S de fichiers pour plus d'informations sur l'utilisation de BunFile.

Bun édité par www.bunjs.com.cn