MIME Detection
Accurate MIME type detection is crucial for handling media assets securely and efficiently.
The API relies on multiple strategies to determine the exact MIME type of a remote URL.
Resolution Strategy
- HTTP Headers: The primary source of truth is the
Content-Typeheader returned by the remote server. - File Extension Fallback: If the server returns a generic
application/octet-streamor no content type at all, the URL is parsed for known media extensions (e.g.,.mp4,.webp). - Magic Byte Inspection (Future): Partial byte fetching to inspect file signatures when headers and extensions are unreliable.
Supported Classifications
The API normalizes detected MIME types into broad classifications to simplify downstream processing.
| Classification | Example MIME Types |
|---|---|
image | image/jpeg, image/png, image/webp, image/gif |
video | video/mp4, video/webm, video/ogg |
audio | audio/mpeg, audio/wav, audio/ogg |
Dealing with Inaccuracies
Many remote servers are misconfigured and return text/plain or application/octet-stream for valid media files. The API prioritizes the remote header but flags potential mismatches if the extension clearly contradicts the declared type.