Detect MIME Type
file.detect_mime
Overview
You give us a managed file reference and we detect its MIME type from content magic bytes, cross-check the filename extension and any declared content type you supply, and flag mismatches (for example a PNG named .txt). We read only a bounded prefix — we never fully parse or render the file. Do not use this when you need deep structural validation of a complex document.
Filenames lie — content-based detection is safer for routing and validation.
Reliability
The same bytes give the same answer on this deployment, though a Tika upgrade can refine a type or a confidence score, so treat the value as version-sensitive rather than frozen forever. A file reference resolves only inside your own tenant; if it has expired or was never yours, you get a validation error saying it is not accessible, and retrying will not change that — upload the file again and pass the new reference. A readLimitBytes outside 1 to 5,242,880 or a mode outside content_first, extension_first, and strict fails the same way, so fix the field and call again. A clean result says what the bytes look like; it never certifies that a file is free of malware.
Context footprint
Returns mimeType, confidence, mismatch flags, optional warnings, and inspection metadata. A successful call costs 5 execution credits.
When to use it
Before you process or route an uploaded file based on its type.
When you need deep structural validation or malware scanning.
Scope
Non-goals
- Does not fully parse or render files
- Does not trust the filename extension alone in content_first mode
- Does not validate archive structure or malware
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
File limits
Constraints this skill applies to your input and generated files. The “Limited by” column shows the static source of each cap; none of these can be raised by upgrading your plan.
| Limit | Value | Limited by |
|---|---|---|
| Maximum size per input file | 5 MiB | Skill and platform maximum |
How we handle your data
What this means
This skill may temporarily store files or intermediate data only to complete execution. Temporary data is protected and automatically deleted.
Squillify guarantees
- Runs inside Squillify
- This skill runs inside Squillify.
- Payloads are not sent to an external service by this skill.
- Temporary execution only storage
- Squillify does not permanently store submitted payloads.
- Telemetry records metadata only, not submitted content.
- Submitted payloads are not used for training.
- Submitted payloads are not reviewed by humans.
- This skill does not target sensitive data.
- The response may contain submitted or transformed content.
Your responsibility
Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.
Input schema
| Field | Type | Required | Description |
|---|---|---|---|
| fileRef | string | Yes | Managed file reference resolved inside the current tenant. |
| filename | string | No | Original filename used for extension hinting; omit it to skip the extension cross-check. |
| declaredContentType | string | No | Content type the client claims; omit it to skip that comparison. |
| readLimitBytes | integer | No | Maximum prefix bytes to inspect; omit it for 1048576. |
| mode | string | No | How content and extension are combined; omit it for content_first. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| ok | boolean | Yes | Always true on success. |
| mimeType | string | Yes | Resolved MIME type for the inspected prefix. |
| extensionMimeType | string | No | MIME type implied by filename; omitted when filename was not supplied. |
| declaredContentType | string | No | Echo of declaredContentType when supplied. |
| confidence | number | Yes | Detection confidence from 0 through 1. |
| mismatch | boolean | Yes | True when resolved type disagrees with extension or declared type. |
| warnings | array | No | Bounded array of 0 through 16 plain-text advisories, where each item is one non-fatal warning string. |
| metadata | object | No | Closed detection metadata naming bytes inspected, mode, and engine. |
API contract
POST /v1/executecurl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"file.detect_mime","input":{"fileRef":"squillify://files/f-1","filename":"report.pdf"}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("file.detect_mime", {"fileRef":"squillify://files/f-1","filename":"logo.txt"});Errors
| Code | HTTP | Retryable | Description |
|---|---|---|---|
| VALIDATION_ERROR | 400 | No | The request payload failed schema validation. |
| UNAUTHORIZED | 401 | No | Missing or invalid API key. |
| SKILL_NOT_ACCESSIBLE | 403 | No | The API key is not granted access to this skill. |
| SKILL_NOT_AVAILABLE_FOR_PLAN | 403 | No | This skill is not included in your current plan. |
| PLAN_ELIGIBILITY_UNAVAILABLE | 503 | Yes | Plan eligibility could not be decided. Retry after backoff. |
| SKILL_NOT_FOUND | 404 | No | The requested skill or version does not exist. |
| TENANT_RATE_LIMITED | 429 | Yes | Request rate limit exceeded. Retry after backoff. |
| QUOTA_EXCEEDED | 429 | Yes | Plan quota exhausted. Retryable once the quota period resets. |
| EXECUTION_TIMEOUT | 504 | Yes | Execution exceeded the allowed time budget. |
Other limits
| Limit | Value |
|---|---|
| Recommended inline bytes | 32 KiB |
Limitations
- Does not fully parse or render files
- Does not trust the filename extension alone in content_first mode
- Does not validate archive structure or malware
- Deep PDF, Office, or media structural validation
- Malware scanning or archive safety checks
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "file.detect_mime",
"input": {
"fileRef": "squillify://files/f-1",
"filename": "logo.txt"
}
}Examples
PNG bytes with a .txt filename — mismatch flagged
{
"fileRef": "squillify://files/f-1",
"filename": "logo.txt"
}{
"confidence": 0.95,
"ok": true,
"mimeType": "image/png",
"mismatch": true,
"metadata": {
"detectionMode": "content_first",
"bytesInspected": 8,
"engine": "tika-core"
},
"extensionMimeType": "text/plain"
}JSON detected from content without a filename hint
{
"fileRef": "squillify://files/f-json"
}{
"mimeType": "application/json",
"ok": true,
"mismatch": false,
"confidence": 0.7,
"metadata": {
"detectionMode": "content_first",
"bytesInspected": 7,
"engine": "tika-core"
}
}Recommended use cases
- Route uploads before downstream processing
- Flag spoofed extensions before extraction
- Pick the right parser skill from content, not filename alone
Avoid for
- Deep PDF, Office, or media structural validation
- Malware scanning or archive safety checks
Related skills
Composable with
Safety & privacy
- Runs without calling any external service.
- Your payloads are never stored permanently.
- Telemetry captures metadata only — never your payload contents.
- We never train models on your payloads.
- No human reviews your payloads.