Skip to content

Documentation / base / guessMimeType

Function: guessMimeType()

guessMimeType(path): string

Defined in: libs/base/src/vfs/common.ts:311

Guesses the MIME type based on a file path or file name.

Behavior:

  • Uses PathUtils.extname to extract the extension (case-insensitive).
  • Falls back to application/octet-stream if unknown.

Notes:

  • The mapping is intentionally minimal and web-oriented.
  • Extend the mimeTypes table if you need additional types.

Examples:

  • guessMimeType('image.png') -> 'image/png'
  • guessMimeType('/a/b/model.glb') -> 'model/gltf-binary'
  • guessMimeType('unknown.ext') -> 'application/octet-stream'

Parameters

path

string

File path or name used to infer the MIME type.

Returns

string

The guessed MIME type string.

Released under the MIT License.