Skip to content

Detect File

Standard · 1 credit

Identify a file’s MIME type, encoding, and category from its binary content.

POST /api/detect-file

FieldTypeRequiredDescription
contentstringYesBase64-encoded file content (up to 10 MB)

POST /api/detect-file/upload

FieldTypeRequiredDescription
filefileYesBinary file to analyze (up to 10 MB)

Both routes return the same shape.

FieldTypeDescription
mime_typestringDetected MIME type, e.g. application/pdf
extensionstringFile extension, e.g. pdf
encodingstringCharacter encoding, e.g. utf-8, binary
descriptionstringHuman-readable file type description
is_textbooleanWhether the file is text-based
is_imagebooleanWhether the file is an image
is_archivebooleanWhether the file is an archive
Terminal window
curl -X POST https://morso.dev/api/detect-file \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"content": "JVBERi0xLjQK"}'

JVBERi0xLjQK is the base64 encoding of the PDF magic header %PDF-1.4\n.

{
"mime_type": "application/pdf",
"extension": "pdf",
"encoding": "binary",
"description": "PDF document",
"is_text": false,
"is_image": false,
"is_archive": false
}
Terminal window
curl -X POST https://morso.dev/api/detect-file/upload \
-H "Authorization: Bearer YOUR_API_KEY" \

Same response shape as above.