Skip to content

Global Helpers

mimeTypes()

mimeTypes() — returns string

Available in: controller, model, test, migrator, migration, tabledefinition Category: Miscellaneous Functions

Returns an associated MIME type based on a file extension.

NameTypeRequiredDefaultDescription
extensionstringyesThe extension to get the MIME type for.
fallbackstringnoapplication/octet-streamThe fallback MIME type to return.
// Get the internally-stored MIME type for `xls`
mimeType = mimeTypes("xls");

// Get the internally-stored MIME type for a dynamic value. Fall back to a MIME type of `text/plain` if it's not found
mimeType = mimeTypes(extension=params.type, fallback="text/plain");