Supported File Formats

uViewFile relies on file signatures (magic numbers) rather than extensions to determine file type.

OS environments inherently trust the file extension provided by the user or the downloader. This is a primary vector for malware distribution. We ignore the extension and analyze the raw bytes.

Document Formats

FormatExtensionMagic Number (Hex)
PDF Document.pdf25 50 44 46 2D
Office Open XML.docx, .xlsx50 4B 03 04
Legacy Office.doc, .xlsD0 CF 11 E0 A1 B1 1A E1
Rich Text Format.rtf7B 5C 72 74 66 31

Executable Formats

FormatExtensionMagic Number (Hex)
Windows PE Executable.exe, .dll4D 5A
Linux ELF Executable.elf, .so7F 45 4C 46
Mach-O Binary.macho, .dylibFE ED FA CE / FE ED FA CF
Java Class.classCA FE BA BE

Image & Media Formats

FormatExtensionMagic Number (Hex)
JPEG Image.jpg, .jpegFF D8 FF E0
PNG Image.png89 50 4E 47 0D 0A 1A 0A
GIF Image.gif47 49 46 38 37 61 / 47 49 46 38 39 61
WebP Image.webp52 49 46 46 ... 57 45 42 50
Pro Tip

Wait, docx is a ZIP?

Yes. Modern Office formats (.docx, .xlsx, .pptx) are actually ZIP archives containing XML files. That's why their magic number (50 4B 03 04) matches standard ZIP files. uViewFile will parse the internal structure to differentiate them.

FAQ

Why does my file show as "application/octet-stream"?

If a file lacks a recognizable magic number, it is treated as raw binary data. This often happens with proprietary game files, encrypted containers, or flat configuration files.

Can a magic number be spoofed?

Yes. Malware authors sometimes prepend fake headers (like a JPEG magic number) to a malicious payload to confuse rudimentary security scanners. This is why deep analysis (entropy, structure validation) is required alongside signature matching.

Internal References

Common Mistakes

MistakeConsequenceBetter Approach
FileReader.readAsArrayBufferBrowser Crash (OOM)Use File.slice for chunks
Rendering full DOMBrowser freezeVirtualized list rendering

FAQ

What is the max file size?

By using slicing and streams, we can handle files limited only by your OS filesystem (e.g., 2TB on NTFS), not your RAM.

Internal References