Skip to main content

Mime type

Validates file extends and mime type

Installation

This requirement is available by default and does not require installation.

Usage

import {RequirementMimeType} from "@farbor/server";

export default {
assets: {
image: {
requirements: [
// new RequirementMimeType(['jpg', 'png']), // only jped and png files are accepted - mime type gets detected automatically
RequirementMimeType.images() // allow all supported image formats
]
}
}
}

JSON representation

OPTIONS /image
{
"collection": "image",
"requirementList": [
{
"type": "mimeType",
"entryList": [
{
"mimeType": "image/jpeg",
"extension": "jpg"
},
{
"mimeType": "image/gif",
"extension": "gif"
},
{
"mimeType": "image/jpeg",
"extension": "jpeg"
},
{
"mimeType": "image/bmp",
"extension": "bmp"
},
{
"mimeType": "image/webp",
"extension": "webp"
},
{
"mimeType": "image/jp2",
"extension": "jp2"
},
{
"mimeType": "image/png",
"extension": "png"
},
{
"mimeType": "image/svg+xml",
"extension": "svg"
}
]
}
]
}