The File Interface
You'll learn how File extends Blob with metadata properties that make working with user-selected files intuitive.
What Is the File Interface?
The File interface is a specialized subclass of Blob that represents files from the user's filesystem. While a Blob is just raw binary data with a type, a File adds essential file metadata: a name, lastModified timestamp, and type (MIME type). You'll encounter File objects when users select files through <input type="file"> or drag-and-drop operations.
The Three Key Properties
Beyond everything Blob provides, File adds:
name: The filename as a string (e.g.,"document.pdf")lastModified: A timestamp in milliseconds since the Unix epoch, indicating when the file was last changedtype: The MIME type (inherited fromBlob, but more meaningful for actual files)
These properties are read-only — you can't rename a file or change its timestamp through the interface.
Why This Matters
When a user uploads a file, you often need more than just the bytes. The filename helps display what they selected, the MIME type guides how you process it (image vs. document), and the timestamp can help with caching or version control. Since File extends Blob, you still have access to size, slice(), and all the reading methods you've already learned.
Analogy: If Blob is like a sealed envelope containing data, File is that same envelope with a return address, postmark date, and label describing its contents.
Key Takeaway: File objects extend Blob by adding name, lastModified, and contextual type metadata, making them the standard representation of user-selected files in web applications.