Detect File
Standard · 1 creditIdentify a file’s MIME type, encoding, and category from its binary content.
Route 1 — JSON
Section titled “Route 1 — JSON”POST /api/detect-file
Parameters
Section titled “Parameters”| Field | Type | Required | Description |
|---|---|---|---|
content | string | Yes | Base64-encoded file content (up to 10 MB) |
Route 2 — Multipart upload
Section titled “Route 2 — Multipart upload”POST /api/detect-file/upload
Parameters
Section titled “Parameters”| Field | Type | Required | Description |
|---|---|---|---|
file | file | Yes | Binary file to analyze (up to 10 MB) |
Response
Section titled “Response”Both routes return the same shape.
| Field | Type | Description |
|---|---|---|
mime_type | string | Detected MIME type, e.g. application/pdf |
extension | string | File extension, e.g. pdf |
encoding | string | Character encoding, e.g. utf-8, binary |
description | string | Human-readable file type description |
is_text | boolean | Whether the file is text-based |
is_image | boolean | Whether the file is an image |
is_archive | boolean | Whether the file is an archive |
Examples
Section titled “Examples”JSON with base64
Section titled “JSON with base64”curl -X POST https://morso.dev/api/detect-file \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"content": "JVBERi0xLjQK"}'
JVBERi0xLjQKis 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}Multipart upload
Section titled “Multipart upload”curl -X POST https://morso.dev/api/detect-file/upload \ -H "Authorization: Bearer YOUR_API_KEY" \Same response shape as above.